( font: string, weights: string, text: string )
| 19 | } |
| 20 | |
| 21 | async function loadGoogleFont( |
| 22 | font: string, |
| 23 | weights: string, |
| 24 | text: string |
| 25 | ): Promise<ArrayBuffer | null> { |
| 26 | try { |
| 27 | const url = `https://fonts.googleapis.com/css2?family=${font}:wght@${weights}&text=${encodeURIComponent(text)}` |
| 28 | const css = await (await fetch(url)).text() |
| 29 | const resource = css.match(/src: url\(([^)]+)\) format\('(opentype|truetype|woff2?)'\)/) |
| 30 | |
| 31 | if (resource) { |
| 32 | const response = await fetch(resource[1]) |
| 33 | if (response.status === 200) { |
| 34 | return await response.arrayBuffer() |
| 35 | } |
| 36 | } |
| 37 | } catch { |
| 38 | return null |
| 39 | } |
| 40 | |
| 41 | return null |
| 42 | } |
| 43 | |
| 44 | interface LandingOgImageProps { |
| 45 | eyebrow: string |
no test coverage detected