fix(metadata): prevent layout title template from applying to the same route-layer page - #3071
Conversation
…e route-layer page (cloudflare#3065)
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a4ba4e96e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const isSameLayerAsPage = | ||
| hasPrimaryPageLayer && layoutInputs[index]?.treePosition === routeSegments.length; |
There was a problem hiding this comment.
Suppress same-layer templates in parallel route branches
When the primary page has no title and an active parallel slot supplies the title, this check only marks layouts from the primary layoutInputs. A slot whose leaf layout and page share a tree position is flattened from resolveParallelRouteMetadata without stashesTitleTemplate: false, so the slot layout still wraps its same-layer page title—for example, producing Slot page | Slot instead of Slot page. Apply the same layer-aware suppression while constructing parallel-route merge entries as well.
AGENTS.md reference: AGENTS.md:L84-L86
Useful? React with 👍 / 👎.
Performance benchmarksCompared 0 improved · 0 regressed · 6 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
Closes #3065
Overview
This PR fixes an App Router metadata compatibility issue where vinext applied a leaf layout's
title.templateto a page on the same route-tree layer. Next.js only propagates that template to deeper child routes.This restores SSR output parity with Next.js, avoiding related SEO and accessibility regressions.
What changed
Added a field
stashesTitleTemplateinMetadataMergeEntryto mark the entries on the same route-tree layer, preventing them from applying the layout's title template.In
packages/vinext/src/server/app-page-head.ts, filter the same route-layer pages.Testing
pnpm test tests/app-page-head.test.ts tests/nextjs-compat/metadata.test.tsplaywright test tests/e2e/app-router/nextjs-compat/metadata.spec.ts --project=app-router