fix(publish): wire the existing seoTitle field into the document <title> - #370
Open
asachs01 wants to merge 1 commit into
Open
fix(publish): wire the existing seoTitle field into the document <title>#370asachs01 wants to merge 1 commit into
asachs01 wants to merge 1 commit into
Conversation
seoTitle is already a fully-built post-type field — declared in the
default field set, seeded by the DB migrations, and editable in the
Content Settings panel's SEO field — but the publish and preview render
paths never consumed it: `renderPublishedDataRowTemplate` and
`handleRowPreview` both set `merged.title` unconditionally from
`row.cells.title`, so the meta-tag `<title>` always fell back to the
plain entry title even when an author filled in a distinct SEO title.
Add `resolveEntryDocumentTitle()` (prefers seoTitle, falls back to
title) and use it at both call sites. The on-page H1 binding
(`{currentEntry.title}`) is unaffected — it resolves from the loop
item's cells directly, never from `merged.title` — so this only
changes what feeds the `<title>` tag / meta description pipeline.
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.
Summary
seoTitleis already a fully-built post-type field — declared inbuildPostTypeDefaultFields(), seeded by both DB migration paths, editable via the Content Settings panel's SEO field, and even exposed to the token/binding picker ({currentEntry.seoTitle}) and the AI content tool — but the publish and preview render paths never actually consume it.renderPublishedDataRowTemplate()(server/publish/publicRenderer.ts) and its preview twinhandleRowPreview()(server/handlers/cms/data/preview.ts) both setmerged.titleunconditionally fromrow.cells.title/draftCells.title. Thatmerged.titleis whatbuildDocumentMetaTags()uses for the<title>tag (src/core/publisher/render.ts), so an author who fills in a distinct SEO title today sees zero effect on the actual<title>output — the field silently does nothing at publish time.Change
resolveEntryDocumentTitle(cells)helper insrc/core/data/cells.ts: prefersseoTitlewhen set (non-empty string), falls back totitle, returnsnullwhen neither is present (preserving today's exact fallback-to-template behavior for rows with no title at all).publicRenderer.ts:182,preview.ts:99) now use this helper instead of the inlinetitle-only check, so publish and preview stay in parity.{currentEntry.title}binding is completely untouched — traced the actual data flow and confirmed it resolves frompublishedDataRowToLoopItem(row)'s spread ofrow.cellsdirectly into the template's entry-stack frame, never throughmerged.title. So this change only ever affects the<title>meta tag, never the visible headline.Test plan
src/__tests__/server/publicRendering.test.ts: a realpostTypes-targeted entry template (not the existing null-early-return fixture) provingseoTitleset →<title>uses it while the H1 binding still renders plaintitle;seoTitleunset → byte-identical fallback.resolveEntryDocumentTitleinsrc/core/data/__tests__/cells.test.ts.bun test).tsc -bclean,eslint .clean.Noticed while working on the trusted-host iframe-embed fix (#369) — same investigation trail, unrelated bug though, so opened as a separate PR for independent review.