Skip to content

feat(layer)!: run on nuxt content v4 - #1499

Draft
larbish wants to merge 8 commits into
mainfrom
feat/content-v4
Draft

larbish wants to merge 8 commits into
mainfrom
feat/content-v4

Conversation

@larbish

@larbish larbish commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Docus runs on Nuxt Content v3, which v4 replaces with comark-content. #1496 showed that v4's compatibility mode works, but it keeps content.config.ts, queryCollection and <ContentRenderer>, which v4 deprecates. This PR moves the layer to pure v4 (compatibilityVersion: 4, server-only, every page prerendered). An app keeps the same config, and its built output stays the same.

  • docus.mode: new option, 'prerender' by default and the only mode for now.
    • It sets content.mode: 'server-only' and content.compatibilityVersion: 4, and warns when an app sets them differently. Any other mode throws at build time.
    • Pages, raw twins, llms.txt, sitemap.md and openapi.json are prerendered as today. The server still answers what has to stay dynamic: MCP, the assistant, sitemap.xml, robots.txt and markdown negotiation.
  • Content sources: the layer ships server/content.ts, with one source per locale (docs_<locale>, fs('content/<locale>', { prefix: '/<locale>' }), landing page included), or one docs source on content/ without i18n. The paths are the same as v3's.
    • Its frontmatter schema is a zod object, converted with z.toJSONSchema(); the layer types its pages from the same object.
    • The sources are decided at build time: locale folders as written on disk, index.md left to an app's app/pages/index.vue, siblings of a docs/ folder excluded. Nitro gets the same list. This moves to fromBuild() once it lands on nuxt/content v4.
    • content.config.ts is removed.
  • Pages:
    • content.get() replaces queryCollection, and <ContentDocument> replaces <ContentRenderer>.
    • The TOC comes from meta.toc, and titles fall back to the leading h1.
    • Prev/next is computed from the navigation, since v4 has no surround query.
    • The navigation is read once for every locale, so switching locale reuses it instead of fetching it again.
  • Agent files: one llms.txt section per locale, landing page included, instead of one per v3 collection. The sitemap source reads content.list().
  • Dependencies:
  • Docs site: AssistantDemo becomes AssistantDemo.lazy.vue. v4 imports components/content/ statically into <ContentDocument>'s component map, and the landing pages share it with the docs pages, so the demo and the AI SDK were preloaded on every docs page.
  • Search: it moves to the browser, in a web worker, so typing never waits on the network.
    • The layer ships app/content.worker.ts with the SQLite FTS plugin, and AppSearch reads the current locale's source through useNuxtContentWorker() (feat: search content in a web worker with app/content.worker.ts nuxt/content#3931).
    • The current locale's snapshot downloads once in the background, from onNuxtReady, then every query runs locally. Switching locale loads that locale's snapshot.
    • It also works with nuxt generate. appConfig.search.fts is deprecated, and the configuration page no longer documents Fuse.js.

Evidence

Fresh main (v3) build compared with this branch, Vercel preset, caches deleted before each build:

static files 145 145
html pages 42 text differs 2 (en and fr configuration pages, Search section rewritten)
openapi.json identical
sitemaps (en, fr) same URLs and lastmod

The new smoke test fails on main and passes here:

main:   AssertionError: en: expected Set{ 'Landing En', 'Docs En' } to deeply equal Set{ 'Landing En' }
branch: Tests  19 passed | 2 skipped (21)

JavaScript preloaded per page (module script and modulepreloads, entry included), gzip:

                                   main (v3)   2e4d5b8   83dd025 (comark#632)   worker search
/en/getting-started/installation   256 kB      314 kB    247 kB                 248 kB
/en/essentials/components          271 kB      330 kB    262 kB                 264 kB
/en                                499 kB      396 kB    397 kB                 398 kB

The worker chunk (content-worker-*.js), sqlite3.wasm and the snapshots aren't preloaded.

Search on nuxt generate, served by a plain static file server, in Chromium:

/en, "installation"  →  Getting Started > Installation, then heading and body matches (Internationalization > Directory Structure, Markdown Syntax > Links, …)
/fr, "installation"  →  Bien démarrer > Installation, then French matches
requests             →  /__nuxt_content/snapshot/docs_en.json once at load, docs_fr.json once on /fr, none per query

New unit tests cover which sources Docus declares: an app index.vue, a docs/ folder, one source per locale, folder case. Lint, typecheck, unit tests (184), the Vercel output check, the static output check, and both starters through test-starter.sh pass locally and in CI.

On a plain static file server, client navigation, prev/next and switching locale make no /__nuxt_content request. nuxt dev from a cold Vite cache hydrates without errors, discovers no dependencies at runtime, and shows markdown edits live.

Notes

ELI5

Docus reads your Markdown through Nuxt Content. Nuxt Content is getting a new engine, and this moves Docus onto it without changing the pages your site produces. Search runs in the visitor's browser, so results appear as you type without asking the server.

🤖 Generated with Amp, reviewed by @larbish before opening.

@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docus Ready Ready Preview Nov 27, 2026 9:33am UTC

Request Review

@pkg-pr-new

pkg-pr-new Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/create-docus@1499
npm i https://pkg.pr.new/docus@1499

commit: 02a3517

@docus-bundle-report

docus-bundle-report Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Bundle size

Explore the comparison →

Client 551.1 kB $\color{green}\textsf{(-223.3 kB, -28.8}\%\textsf{)}$ · Server 1.25 MB $\color{green}\textsf{(-340.8 kB, -21.4}\%\textsf{)}$

Initial page load PR Δ
/en/:lang? 224.2 kB −6.83 kB (−3.0%)
/fr/:lang? 224.2 kB −6.83 kB (−3.0%)
/en/:lang?/:slug(.) 232.6 kB −6.60 kB (−2.8%)
/fr/:lang?/:slug(.) 232.6 kB −6.60 kB (−2.8%)
/sitemap.xml 214.1 kB −4.88 kB (−2.2%)
Prerendered URL Initial load Δ HTML Δ
/en 371.2 kB
147.0 kB from components
−84.7 kB (−18.6%)
route −6.83 kB, components −77.9 kB
15.4 kB −1.02 kB (−6.2%)
/en/essentials/images-embeds 283.4 kB
50.8 kB from components
−6.81 kB (−2.3%)
route −6.60 kB, components −209 B
15.9 kB −844 B (−5.1%)
/en/getting-started/installation 240.2 kB
7.66 kB from components
−6.77 kB (−2.7%)
route −6.60 kB, components −166 B
16.8 kB −919 B (−5.2%)
/en/essentials/components 254.5 kB
21.9 kB from components
−6.76 kB (−2.6%)
route −6.60 kB, components −154 B
20.5 kB −1.20 kB (−5.5%)
/en/essentials/code-blocks 248.0 kB
15.4 kB from components
−6.74 kB (−2.6%)
route −6.60 kB, components −138 B
21.1 kB −1.20 kB (−5.4%)
Largest changes in the client
Package or file Base PR Δ
node_modules/@shikijs/langs 81.0 kB n/a −81.0 kB (−100.0%)
node_modules/@sqlite.org/sqlite-wasm 54.9 kB n/a −54.9 kB (−100.0%)
node_modules/comark 33.1 kB 22.3 kB −10.8 kB (−32.6%)
node_modules/rangi n/a 9.64 kB +9.64 kB
node_modules/@shikijs/vscode-textmate 9.19 kB n/a −9.19 kB (−100.0%)
node_modules/nuxt-studio 8.79 kB n/a −8.79 kB (−100.0%)
node_modules/oniguruma-to-es 7.04 kB n/a −7.04 kB (−100.0%)
[unassigned] 77.3 kB 70.4 kB −6.93 kB (−9.0%)
node_modules/oniguruma-parser 6.91 kB n/a −6.91 kB (−100.0%)
node_modules/minimatch 5.99 kB n/a −5.99 kB (−100.0%)

And 37 more packages or files.

Largest changes in the server
Package or file Base PR Δ
content/database.compressed.mjs 149.1 kB n/a −149.1 kB (−100.0%)
node_modules/@shikijs/langs 77.3 kB n/a −77.3 kB (−100.0%)
[unassigned] 291.1 kB 266.8 kB −24.3 kB (−8.4%)
node_modules/nuxt-studio 14.8 kB n/a −14.8 kB (−100.0%)
node_modules/@shikijs/vscode-textmate 12.0 kB n/a −12.0 kB (−100.0%)
node_modules/oniguruma-to-es 10.2 kB n/a −10.2 kB (−100.0%)
node_modules/rangi n/a 10.1 kB +10.1 kB
node_modules/@nuxt/content 9.81 kB n/a −9.81 kB (−100.0%)
node_modules/oniguruma-parser 7.45 kB n/a −7.45 kB (−100.0%)
node_modules/@shikijs/core 6.33 kB n/a −6.33 kB (−100.0%)

And 49 more packages or files.

Brotli sizes. Changes under 100 B are left out of the tables. Initial page load counts the JavaScript and CSS a route loads before it renders. Prerendered URLs count the JavaScript and CSS their HTML preloads (module scripts, modulepreload and stylesheets, not prefetch), and the HTML document. Components are the lazy-loaded components the page rendered: its HTML preloads them, but its route's static imports don't reach them. Measured by nuxt-bundle-analyzer for 02a3517.

This branch was successfully deployed

1 active deployment
Preview — 02a35170 Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant