fix(publish): interpolate entry tokens in page meta title and description - #337
Open
mostafasadeghidev wants to merge 1 commit into
Open
Conversation
…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
marked this pull request as ready for review
August 3, 2026 03:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
{currentEntry.*}/{page.*}/{site.*}tokens in the meta title, meta description, and the page-title fallback were published verbatim:buildDocumentMetaTagsreadsettings.metaTitle ?? page.title ?? site.nameraw, so every CMS entry route (e.g./articles/:slug) rendered the template page's static<title>. It now receives the composedTemplateRenderDataContextand runs the title + description throughinterpolateTokensbeforeescapeHtml.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 — theentryStackthe 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} | Acmein 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 thecontainsTokensfast path.slugToFilenameneeds 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) andbun run lint— cleanbun teston the Windows dev box: 318 pre-existing environment failures (EBUSYtmp-db cleanup /EPERMsymlink), verified identical on the base commit with this diff stashed