Docs Updates #2 - Stable IDs for Content + Redirects#666
Open
bryantgillespie wants to merge 10 commits into
Open
Docs Updates #2 - Stable IDs for Content + Redirects#666bryantgillespie wants to merge 10 commits into
bryantgillespie wants to merge 10 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR adds “stableId” frontmatter support and related tooling to keep Nuxt Content page identity stable across file moves, and introduces a redirects manifest + runtime routeRules loader to preserve old URLs.
Changes:
- Add scripts to backfill/check
stableIdvalues and to generate/syncredirects.jsonbased on moved/removed routes. - Configure git hooks (via
postinstall) to auto-insert stable IDs on commit and validate redirects on push. - Load
redirects.jsoninto Nuxt/NitrorouteRulesand extend the content schema to acceptstableId.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/tsconfig.json | Adds a dedicated TS config for typechecking repo scripts. |
| scripts/setup-hooks.ts | Configures .githooks as core.hooksPath during postinstall when appropriate. |
| scripts/_content-lib.ts | Adds content scoping + minimal frontmatter parsing + stableId insertion helpers. |
| scripts/ensure-stable-ids.ts | Script to insert missing stableId into (optionally staged) content files. |
| scripts/check-stable-ids.ts | Script to validate presence/format of stableId across in-scope content. |
| scripts/redirects-sync.ts | Script to diff routes vs a base ref and update/report redirect coverage. |
| .githooks/pre-commit | Runs stable-id insertion for staged docs changes before commit. |
| .githooks/pre-push | Runs redirects coverage check for docs-related changes before push. |
| redirects.json | Adds initial redirect manifest file (currently empty). |
| nuxt.config.ts | Loads redirects.json into Nitro routeRules; centralizes baseURL constant. |
| content.config.ts | Extends content collection schema to allow stableId as a UUID. |
| package.json | Adds tooling scripts, hook setup on postinstall, and Node engine constraint. |
| README.md | Documents tooling commands and updates Node version requirement wording. |
| pnpm-lock.yaml | Locks updated dependency graph (incl. @types/node alignment). |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+135
to
+152
| for (const old of basePages) { | ||
| if (currentPaths.has(old.path) || manifest[old.path]) continue; | ||
|
|
||
| if (!old.stableId) { | ||
| unresolved.push({ page: old, reason: 'no stableId in base ref', matches: [] }); | ||
| continue; | ||
| } | ||
|
|
||
| const matches = (currentByStableId.get(old.stableId) ?? []).filter(p => p.path !== old.path); | ||
| if (matches.length === 1) { | ||
| resolved.push({ from: old.path, to: matches[0].path }); | ||
| } | ||
| else if (matches.length > 1) { | ||
| unresolved.push({ page: old, reason: 'multiple current routes share stableId', matches }); | ||
| } | ||
| else { | ||
| unresolved.push({ page: old, reason: 'no current route with same stableId', matches: [] }); | ||
| } |
Comment on lines
16
to
22
| title: z.string(), | ||
| description: z.string().optional(), | ||
| headline: z.string().optional(), | ||
| stableId: z.string().uuid().optional(), | ||
| authors: z.array(z.object({ | ||
| name: z.string(), | ||
| title: z.string(), |
| exit 0 | ||
| fi | ||
|
|
||
| echo "Checking redirects for docs changes..." |
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.
This PR introduces
stableIdfor all content to ensure we don't break URLs and links when re-arranging content. This is necessary because Nuxt Content auto generates IDs based on the the file path so changing the path (url) also generates a new ID for that content.It also adds tooling scripts and support for automatically generating ids and redirects.