-
Notifications
You must be signed in to change notification settings - Fork 253
feat: add error code documentation routing #2219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
danielroe
wants to merge
3
commits into
main
Choose a base branch
from
feat/error-code-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /** | ||
| * Redirect unversioned error doc paths to the current default version. | ||
| * | ||
| * The Nuxt runtime links to https://nuxt.com/docs/errors/E1001 (unversioned). | ||
| * This middleware redirects those paths to the current default docs version | ||
| * (e.g., /docs/4.x/errors/E1001) so the content can be resolved. | ||
| */ | ||
| export default defineEventHandler((event) => { | ||
| const path = getRequestURL(event).pathname | ||
|
|
||
| // Match /docs/errors/... but NOT /docs/3.x/errors/... or /docs/4.x/errors/... | ||
| const match = path.match(/^\/docs\/errors\/(.+)$/) | ||
| if (match) { | ||
| // TODO: update to /docs/5.x when Nuxt 5 is the default | ||
| return sendRedirect(event, `/docs/4.x/errors/${match[1]}`, 302) | ||
| } | ||
| }) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /** | ||
| * Short URL handler for Nuxt error codes. | ||
| * | ||
| * Redirects /e/NUXT_E1001 → /docs/4.x/errors/E1001 | ||
| * Redirects /e/NUXT_B1001 → /docs/4.x/errors/B1001 | ||
| * | ||
| * The error code format is NUXT_ followed by E or B and 1-4 digits. | ||
| * The NUXT_ prefix is stripped and the user is redirected to the | ||
| * current default docs version. | ||
| */ | ||
| export default defineEventHandler((event) => { | ||
| const code = getRouterParam(event, 'code') | ||
|
|
||
| // Validate: must be NUXT_ followed by E or B and 1-4 digits | ||
| if (!code || !/^NUXT_[EB]\d{1,4}$/.test(code)) { | ||
| throw createError({ statusCode: 404, statusMessage: 'Not found' }) | ||
| } | ||
|
|
||
| // Strip the NUXT_ prefix → E1001 or B1001 | ||
| const errorCode = code.replace('NUXT_', '') | ||
|
|
||
| // TODO: update to /docs/5.x when Nuxt 5 is the default | ||
| return sendRedirect(event, `/docs/4.x/errors/${errorCode}`, 302) | ||
| }) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid shipping a feature-branch fallback for v4 docs source.
Line 14 points to
feat/error-context, and with default envs this becomes the effective source. That’s risky for merge/release because it can drift or break when the feature branch changes. Please revert the fallback to4.xbefore merge (or gate preview branch selection behind an explicit env var).Suggested fix
const docsV4Source = { cwd: process.env.NUXT_V4_PATH ?? undefined, - // TODO: revert to 4.x branch before merging - repository: !process.env.NUXT_V4_PATH ? 'https://github.com/nuxt/nuxt/tree/feat/error-context' : undefined, + repository: !process.env.NUXT_V4_PATH ? 'https://github.com/nuxt/nuxt/tree/4.x' : undefined, include: 'docs/**/*', exclude: ['docs/**/*.json'], prefix: '/docs/4.x' }📝 Committable suggestion
🤖 Prompt for AI Agents