Repository navigation
feat(pages): allow titleTemplate in middleware headDefaults - #797
Open
karthickeyan-dev wants to merge 1 commit into
Open
karthickeyan-dev wants to merge 1 commit into
karthickeyan-dev wants to merge 1 commit into
Conversation
…ev#796. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Closes #796
Summary
titleTemplatecould only be set once, for the whole site, invoid.config.ts.headDefaultswas typedHeadDescriptor, which has notitleTemplate, andresolveHead()read the template only from the config. So one section of a site couldn't have its own title suffix.packages/void/src/runtime/handler.ts:headDefaultsis now typedHeadConfig, soc.set('headDefaults', { titleTemplate })type-checks.packages/void/src/pages/head.ts:resolveHead()uses the middleware'stitleTemplateand falls back to the config's. The resolved head still doesn't includetitleTemplate.packages/void/src/pages/protocol.ts: the threeheadDefaultsreads cast toHeadConfig.docs/guide/pages-routing/head.md: an example under Middleware defaults, and thetitlerow in the precedence table.A page returning
{ title: "Users" }under/adminnow renders<title>Users | Admin</title>. Sites that don't settitleTemplatein middleware see no change.Tests
pages-head.test.ts: the middleware template wins over the config's, applies when the config has none, falls back to the config's when middleware doesn't set one, and isn't emitted in the resolved head.routing-runtime.test.ts: adefineMiddlewareon/admin/*sets the template, andcreatePageGetHandlerreturnsUsers | Adminunder/adminandUsers | My Siteelsewhere.4 of the new cases fail without the fix. Without the fix, the runtime test also fails to type-check (
TS2769onc.set).Verification
vp run check: 33/33 passvp test run: 792 files pass, 1 skipped (16,676 tests pass, 37 skipped)🤖 Generated with Claude Code