ReviewOS

also looking at this

stacks/bench-review

Adopt the hq-apps app conventions

#76
Merged glennmichael123 wants to merge chore/hq-apps-conventions into main
31 files +1656 -395
app/Helpers/seoPages.tsmodified+10-7
Changes to app/Helpers/seoPages.ts
@@ -14,6 +14,8 @@
1414 * they need build-time static generation (#46).
1515 */
1616
17import site from '~/site.config'
18
1719interface PageSeo {
1820 /** Public path, e.g. '/judges'. Canonical + og:url = base + path. */
1921 path: string
@@ -105,7 +107,7 @@ export const escapeAttr = (s: string): string =>
105107/** Extract the page's existing <title> text for og__stx_title="IkFkb3B0IHRoZSBocS1hcHBzIGFwcCBjb252ZW50aW9ucyBieSBnbGVubm1pY2hhZWwxMjMgwrcgc3RhY2tzL2JlbmNoLXJldmlldyAjNzYi" / twitter:title. */
106108function extractTitle(html: string): string {
107109 const m = html.match(/<title>([^<]*)<\/title>/i)
108 return m?.[1]?.trim() || 'Bench Review'
110 return m?.[1]?.trim() || site.seo.siteName
109111}
110112
111113/**
@@ -140,18 +142,18 @@ function buildJsonLd(seo: PageSeo, base: string, title: string): string {
140142 {
141143 '@type': 'Organization',
142144 '@id': `${base}/#organization`,
143 'name': 'Bench Review',
145 'name': site.seo.siteName,
144146 'url': `${base}/`,
145147 'logo': {
146148 '@type': 'ImageObject',
147 'url': `${base}/images/bench/logo.png`,
149 'url': `${base}${site.seo.logo}`,
148150 },
149151 },
150152 {
151153 '@type': 'WebSite',
152154 '@id': `${base}/#website`,
153155 'url': `${base}/`,
154 'name': 'Bench Review',
156 'name': site.seo.siteName,
155157 'publisher': { '@id': `${base}/#organization` },
156158 'potentialAction': {
157159 '@type': 'SearchAction',
@@ -186,12 +188,13 @@ export function injectSeoHead(html: string, seo: PageSeo, base: string): string
186188 const url = `${base}${seo.path}`
187189 const title = extractTitle(html)
188190 const ogDesc = seo.ogDescription ?? seo.description
189 const ogImage = `${base}/images/og-image.png`
191 const ogImage = `${base}${site.seo.imagePath}`
190192
191193 const tags = [
192194 `<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)}">`,
195198 `<meta property="og:url" content="${escapeAttr(url)}">`,
196199 `<meta property="og:title" content="${escapeAttr(title)}">`,
197200 `<meta property="og:description" content="${escapeAttr(ogDesc)}">`,