fix(seo): use body H1 as case-file <title> and OG title
generateMetadata still derived the page <title>/OG title from the generic
auto frontmatter topic ("Dow Uap D44 …"). Search engines, link cards, and
AI crawlers show that string, so it must be the human magazine headline the
narrator wrote as the body H1. Mirror the page component's H1 extraction.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
aaf5618466
commit
e45f1c04d0
1 changed files with 8 additions and 1 deletions
|
|
@ -81,7 +81,14 @@ export async function generateMetadata(
|
|||
const c = await loadCase(slug);
|
||||
if (!c) return { title: "Case file not found" };
|
||||
|
||||
const title = locale === "pt-br" ? (c.fm.topic_pt_br ?? c.fm.topic ?? slug) : (c.fm.topic ?? slug);
|
||||
// Prefer the narrator's body H1 (the magazine headline) over the generic
|
||||
// auto-derived frontmatter topic ("Dow Uap D44 …"). This is what search
|
||||
// engines and link cards show, so it must be the human title. Two H1s when
|
||||
// present: EN then PT-BR; fall back across them, then to frontmatter.
|
||||
const h1s = [...c.body.matchAll(/^#\s+(.+)$/gm)].map((m) => m[1].trim());
|
||||
const title = locale === "pt-br"
|
||||
? (h1s[1] ?? h1s[0] ?? c.fm.topic_pt_br ?? c.fm.topic ?? slug)
|
||||
: (h1s[0] ?? c.fm.topic ?? slug);
|
||||
const desc = pickLead(c.body, locale).slice(0, 200);
|
||||
const canonical = `${SITE_URL}/c/${slug}`;
|
||||
// OG image — use the case's editorial illustration when present. WhatsApp,
|
||||
|
|
|
|||
Loading…
Reference in a new issue