also looking at this
Adopt the hq-apps app conventions
#76
31 files
+1656
-395
| @@ -14,6 +14,8 @@ | ||
| 14 | 14 | * they need build-time static generation (#46). |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | import site from '~/site.config' | |
| 18 | ||
| 17 | 19 | interface PageSeo { |
| 18 | 20 | /** Public path, e.g. '/judges'. Canonical + og:url = base + path. */ |
| 19 | 21 | path: string |
| @@ -105,7 +107,7 @@ export const escapeAttr = (s: string): string => | ||
| 105 | 107 | /** Extract the page's existing <title> text for og__stx_title="IkFkb3B0IHRoZSBocS1hcHBzIGFwcCBjb252ZW50aW9ucyBieSBnbGVubm1pY2hhZWwxMjMgwrcgc3RhY2tzL2JlbmNoLXJldmlldyAjNzYi" / twitter:title. */ |
| 106 | 108 | function extractTitle(html: string): string { |
| 107 | 109 | const m = html.match(/<title>([^<]*)<\/title>/i) |
| 108 | return m?.[1]?.trim() || 'Bench Review' | |
| 110 | return m?.[1]?.trim() || site.seo.siteName | |
| 109 | 111 | } |
| 110 | 112 | |
| 111 | 113 | /** |
| @@ -140,18 +142,18 @@ function buildJsonLd(seo: PageSeo, base: string, title: string): string { | ||
| 140 | 142 | { |
| 141 | 143 | '@type': 'Organization', |
| 142 | 144 | '@id': `${base}/#organization`, |
| 143 | 'name': 'Bench Review', | |
| 145 | 'name': site.seo.siteName, | |
| 144 | 146 | 'url': `${base}/`, |
| 145 | 147 | 'logo': { |
| 146 | 148 | '@type': 'ImageObject', |
| 147 | 'url': `${base}/images/bench/logo.png`, | |
| 149 | 'url': `${base}${site.seo.logo}`, | |
| 148 | 150 | }, |
| 149 | 151 | }, |
| 150 | 152 | { |
| 151 | 153 | '@type': 'WebSite', |
| 152 | 154 | '@id': `${base}/#website`, |
| 153 | 155 | 'url': `${base}/`, |
| 154 | 'name': 'Bench Review', | |
| 156 | 'name': site.seo.siteName, | |
| 155 | 157 | 'publisher': { '@id': `${base}/#organization` }, |
| 156 | 158 | 'potentialAction': { |
| 157 | 159 | '@type': 'SearchAction', |
| @@ -186,12 +188,13 @@ export function injectSeoHead(html: string, seo: PageSeo, base: string): string | ||
| 186 | 188 | const url = `${base}${seo.path}` |
| 187 | 189 | const title = extractTitle(html) |
| 188 | 190 | const ogDesc = seo.ogDescription ?? seo.description |
| 189 | const ogImage = `${base}/images/og-image.png` | |
| 191 | const ogImage = `${base}${site.seo.imagePath}` | |
| 190 | 192 | |
| 191 | 193 | const tags = [ |
| 192 | 194 | `<link rel="canonical" href="${escapeAttr(url)}">`, |
| 193 | `<meta property="og:type" content="website">`, | |
| 194 | `<meta property="og:site_name" content="Bench Review">`, | |
| 195 | `<meta property="og:type" content="${escapeAttr(site.seo.type)}">`, | |
| 196 | `<meta property="og:site_name" content="${escapeAttr(site.seo.siteName)}">`, | |
| 197 | `<meta property="og:locale" content="${escapeAttr(site.seo.locale)}">`, | |
| 195 | 198 | `<meta property="og:url" content="${escapeAttr(url)}">`, |
| 196 | 199 | `<meta property="og:title" content="${escapeAttr(title)}">`, |
| 197 | 200 | `<meta property="og:description" content="${escapeAttr(ogDesc)}">`, |