docs: render minimalVersion badge from layout - #2203
Conversation
- Add minimalVersion to docs collection schemas (docsv3, docsv4, docsv5) - Render version badge in docs page header when frontmatter has minimalVersion - Badge shows vX.Y (e.g. v3.12), info color, with aria-label for a11y Complements nuxt/nuxt#34485: API docs set minimalVersion in frontmatter; this repo displays the badge so global inline badges are not needed.
|
@Ibochkarev is attempting to deploy a commit to the Nuxt Team on Vercel. A member of the Team first needs to authorize it. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds an optional Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@content.config.ts`:
- Around line 217-220: The schema currently defines minimalVersion as
z.string().optional(), which rejects numeric YAML frontmatter and leaves
templates calling page.minimalVersion?.trim() unsafe; update the schema for
minimalVersion to accept z.union([z.string(),
z.number()]).optional().transform(v => v === undefined ? undefined :
String(v).trim()) so numbers like 3.12 become trimmed strings, and apply the
same change to the other occurrences of minimalVersion in the file (the other
schema blocks near the same section) to keep behavior consistent with the Vue
template.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a5ddbb40-498b-456d-b52c-e9080128d9a8
📒 Files selected for processing (2)
app/pages/docs/[...slug].vuecontent.config.ts
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
Co-authored-by: Robin <robin.kehl@singular-it.de>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@content.config.ts`:
- Line 221: Update the minimalVersion schemas at all three occurrences in the
content configuration to accept both YAML strings and numbers, then normalize
either input to a trimmed string while preserving undefined values. Replace the
current z.string()-only validation used by each minimalVersion field.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Co-authored-by: Robin <robin.kehl@singular-it.de>
Co-authored-by: Robin <robin.kehl@singular-it.de>
Co-authored-by: Robin <robin.kehl@singular-it.de>
Co-authored-by: Robin <robin.kehl@singular-it.de>
|
failure is: |
Removes the z.preprocess wrapper around minimalVersion in the docsv3/ docsv4/docsv5 collection schemas in favor of a plain z.string().optional(). Trimming is now done consistently in the docs page template instead. This is a defensive simplification; it does not touch the underlying cause of the Vercel preview build failure (SQLITE_UNKNOWN: table _content_docsv3 has 13 columns but 14 values were supplied), which looks like a stale/pre-existing _content_docsv3 table on the preview's content database predating this schema change. Nuxt Content only ever emits CREATE TABLE IF NOT EXISTS (never ALTER TABLE), so an existing table with the old 13-column shape won't pick up the new column automatically; a redeploy without build cache is likely needed to fully resolve the build failure.
I have a WIP followup that includes this: #2327 Hugo 🤝 Robin |
|
@OrbisK I saw that you approved the PR, didn't you want to add the badges to the navigation first? |
My PR is based on this one. I wanted to wait until this one was approved. Should we merge mine into this one, or should we merge both into main separately? I can finish my PR today! |
I don't mind merging this one now and wait for your PR later, thoughts @danielroe @atinux ? |
Keeps the VersionBadge component (tolerance-aware) over the inline UBadge from the PR, and takes the PR's simplified `minimalVersion: z.string()` content schema. Also brings in upstream main, which the PR head had merged.


Render the minimal Nuxt version badge in the docs page layout when
minimalVersionis set in frontmatter, so API docs in nuxt/nuxt do not need to repeat global badges in each markdown file.Why: In nuxt/nuxt#34485, API pages get
minimalVersionin frontmatter. OrbisK suggested rendering the badge from the layout here instead of inline in every doc. This change adds that: the docs layout readsminimalVersionand shows avX.Ybadge next to the page title.Changes:
minimalVersionto docs collection schemas (docsv3, docsv4, docsv5) incontent.config.ts.[...slug].vue, render a small info badge next to the title whenpage.minimalVersionis present; use:aria-labelfor accessibility.Refs nuxt/nuxt#34485