fix(seo-head): build URLs from config.url, not $page.url.origin#9
fix(seo-head): build URLs from config.url, not $page.url.origin#9jaysin586 wants to merge 1 commit into
Conversation
During SvelteKit prerender, `$page.url.origin` resolves to the sentinel
`http://sveltekit-prerender`. SvelteKit rewrites this placeholder in
`<link href>` attributes but NOT inside `<meta content="...">` — so
og:image and twitter:image have been leaking the placeholder origin into
production HTML, breaking Twitter/X, LinkedIn, Slack, Discord, and
Facebook social previews. Canonical and og:url happen to render correctly
today purely because SvelteKit post-processes `<link href>` and href-like
attrs; relying on that is brittle.
Switch SeoHead to build canonical, og:image, og:url, and twitter:image
from `config.url` (already required in DocsKitConfig). A small
`siteOrigin` derived strips a trailing slash defensively so consumers can
configure `url` with or without one.
Verified on markdown.svelte.page: 10 `/compare/vs-*` pages currently emit
`http://sveltekit-prerender/social-cards/og-compare-vs-{slug}.png`. The
PNGs already exist at the correct path — this is purely a URL-resolution
bug. Once consumers bump docs-kit, the previews start working
immediately.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughSeoHead component updates SEO URL generation to use site configuration instead of page origin. A new ChangesSEO URL Derivation from Site Configuration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Problem
Every consumer of docs-kit ships
<meta property="og:image">URLs that leak SvelteKit's internal prerender hostname into the production HTML:That
http://sveltekit-prerenderis the sentinel origin SvelteKit uses during prerender. It rewrites this placeholder in<link href>attributes and similar href-like contexts — but not inside<meta content="...">values. Soog:imageandtwitter:imagecarry the placeholder into the static HTML, and every social previewer (Twitter/X, LinkedIn, Slack, Discord, Facebook…) sees a connection-level failure (HTTP 000) trying to fetch from a hostname that doesn't resolve.Canonical and
og:urlhappen to render with the right origin today only because SvelteKit post-processes<link href>attrs. Brittle.Fix
SeoHead.sveltenow builds URLs fromconfig.url(already required inDocsKitConfig) rather than$page.url.origin. AsiteOriginderived strips a trailing slash defensively so consumers can passurlwith or without one.The four affected emissions are now stable across SSR, prerender, and runtime:
<link rel="canonical"><meta property="og:url"><meta property="og:image"><meta name="twitter:image">Verification
Reproduced on
markdown.svelte.page(all 10/compare/vs-*pages):http://sveltekit-prerenderhttps://markdown.svelte.pageThe PNGs themselves already exist at the correct paths in
static/social-cards/— this is purely a URL-resolution bug. Once each consumer repo bumps docs-kit and rebuilds, their social previews start working.Scope of consumer impact
Every consumer of
@humanspeak/docs-kitinherits the fix on next pin bump —svelte-markdown,svelte-motion,svelte-headless-table,svelte-virtual-list,svelte-virtual-chat,svelte-json-view-lite,memory-cache,svelte-purify,svelte-diff-match-patch,svelte-page. No app code changes required — only a dependency pin update.Notes on the diff
Prettier also reformatted some pre-existing nested-ternary indentation on the same file (
resolvedTitle,resolvedDescription). Those changes are semantically identical — only style. File now passesprettier --checkandsvelte-checkcleanly.🤖 Generated with Claude Code