Skip to content

fix(publish): interpolate entry tokens in page meta title and description - #337

Open
mostafasadeghidev wants to merge 1 commit into
CoreBunch:mainfrom
mostafasadeghidev:fix/interpolate-entry-tokens-in-page-meta
Open

fix(publish): interpolate entry tokens in page meta title and description#337
mostafasadeghidev wants to merge 1 commit into
CoreBunch:mainfrom
mostafasadeghidev:fix/interpolate-entry-tokens-in-page-meta

Conversation

@mostafasadeghidev

Copy link
Copy Markdown

What

{currentEntry.*} / {page.*} / {site.*} tokens in the meta title, meta description, and the page-title fallback were published verbatim: buildDocumentMetaTags read settings.metaTitle ?? page.title ?? site.name raw, so every CMS entry route (e.g. /articles/:slug) rendered the template page's static <title>. It now receives the composed TemplateRenderDataContext and runs the title + description through interpolateTokens before escapeHtml.

Why

SEO: entry routes shipped the template's own title (e.g. <title>Articles — Template</title> on every article) instead of a per-entry one. The data needed to fix it — the entryStack the server already seeds for dynamic bindings — was composed a few lines above and simply not threaded into the meta builder.

Impact

Authors can write {currentEntry.name} | Acme in the page's meta title (or title a template page with tokens) and get per-entry <title> / description. Plain pages resolve entry tokens to '' or the token's own |fallback; token-free strings are byte-identical via the containsTokens fast path. slugToFilename needs no treatment (entry-route paths come from the route table; the whitelist-strip already sanitizes brace syntax) and the builder has no OG tags to treat.

Verification

  • bun test src/__tests__/publisher/ src/__tests__/templates/ — 484 pass, 0 fail (5 new meta-interpolation tests, including XSS escaping of interpolated values)
  • bun run build (tsc + vite) and bun run lint — clean
  • Full bun test on the Windows dev box: 318 pre-existing environment failures (EBUSY tmp-db cleanup / EPERM symlink), verified identical on the base commit with this diff stashed

…tion

{currentEntry.*} / {page.*} / {site.*} tokens in site metaTitle,
metaDescription, and the page-title fallback were published verbatim
(and pre-escape, effectively static), so every CMS entry route rendered
the template page's static <title> instead of a per-entry SEO title.

buildDocumentMetaTags now receives the composed TemplateRenderDataContext
(the same frames dynamic text bindings resolve against) and runs the
title + description through interpolateTokens before escapeHtml. Entry
routes resolve {currentEntry.name} from the entryStack seeded by
renderPublishedDataRowTemplate; plain pages resolve entry tokens to ''
(or the token's own |fallback) with no leaked placeholder syntax, and
token-free strings are untouched via the containsTokens fast path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mostafasadeghidev
mostafasadeghidev marked this pull request as ready for review August 3, 2026 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant