Repository navigation
Conversation
…search BREAKING CHANGE: the Global Config content pin (`GLOBAL_CONFIG`, `contentSha`) is removed. Production content is read from `/__nuxt_content/**`. Amp-Thread-ID: https://ampcode.com/threads/T-01a21f0d-7e86-7326-bad4-c690c2a760ed
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
Documentation previews📚 Preview all documentation changes (follows new pushes) Pinned to the current head: |
# Conflicts: # nuxt.config.ts # package.json # pnpm-lock.yaml
This branch had an error being deployed
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.
Moves the layer onto Nuxt Content v4, which brings two features comark-docs carried its own code for:
livenuxt/content#3936): the site serves the commit a function returns, and a push goes live through the webhook with no build.app/content.worker.tsnuxt/content#3931): the browser search runs in Nuxt Content's worker, loading the snapshot of the commit being read. This replaces refactor(search): run browser search on comark-content's worker API #102, which tested the same API directly.The layer keeps the webhook's checks and purge, versioned previews, the per-commit routes and ISR.
How the content is declared
The layer declares its content once, in
server/content.ts:Server code reads it through two auto-imported functions:
What happens at runtime:
lastCommit()for the commit and reads the files at that commit from GitHub. It ships them parsed in the function, stamped with the commit.maxAge. Older or missing,lastCommit()is asked again and the answer is stored. Every server reads the same entry, so a visit never mixes two commits.revalidateContent(). It stores the new commit, compares the two commits and returns the pages that changed. The layer turns them into URLs (page, payload, raw twin, every page whennavigationis true, and the global indexes) and purges them from ISR.maxAge(1 hour on production, 10 minutes elsewhere), and the next request finds the push.Pages read the same content through Nuxt Content's client on
/__nuxt_content.How search works
The worker is declared in the layer, so sqlite-wasm stays out of the pages' bundle:
useSearch()wrapsuseNuxtContentWorker()and tells it which commit to load:/api/content/blob/<sha>/snapshot/default.json. That URL never changes for a commit, so ISR keeps it forever, and the webhook warms the new one after a push.basePathis unset and the worker reads the dev server, which follows the working tree.What changed
server/content.tsas above. Server routes (RSS, sitemap, llms, agent discovery, MCP, assistant, history, head route, payload ETag) callresolveContent(content).modules/configpasses the repository, branch, content directory and highlighter hash throughprocess.env.COMARK_DOCS_CONTENT, inlined withnitro.replace.server/content.tsalso runs at build, outside Nitro, whereuseRuntimeConfig()doesn't exist.revalidateContent(). It answersfrom,to,navigationandpagesinstead ofmanifest.app/content.worker.tsanduseNuxtContentWorker()as above. The layer's worker, its logger andnuxt-workersare removed.content.withRef(sha).@sqlite.org/sqlite-wasm,modules/snapshot,utils/factory.ts, the production/api/content/**route, and their tests.node --import test/fixtures/github-mock.mjs). Two e2e tests cover the edit link and the RSS dates.Evidence
A build of
main(a3ebf99) and of this branch were served at the same commit, and 88 responses were captured from each. Identical: the text of all 16 pages, status codes, cache headers, ETags, raw twins,llms.txt,llms-full.txt,sitemap.md,rss.xml, previews, and the ISR configs of the Vercel output./__nuxt_content/listitems no longer carrymeta.toc, which nothing reads.The same test file passes on
main. Purge sets: 8 purged and 2 warmed for one page, 60 and 2 for a title change.Search in a real browser gives the same results as
mainforvitesse,webhook,pull requestandzzzznothing:/blob/96c1546…, wherevitessefinds nothingnuxt devfrom a cold Vite cache, and on a dev previewIt also finds a section pushed after the deploy.
JavaScript preloaded per page (gzip): docs pages go from 928,063 to 845,155 bytes,
/from 420,222 to 338,642. The old search worker was preloaded on every page, Nuxt Content's isn't.Notes
livenuxt/content#3936 fixes two bugs. Pinned to@nuxt/content@b771912. CI fails atpnpm dev:prepareon it, and every check and number above was measured with these two fixes applied by hand innode_modules:server/content.tswithout the app's aliases orimport.meta.dev:Cannot find module '#comark-docs/highlighter'.v3Enabled()readsimport.meta.content?.compatibilityVersion, whichnitro.replacedoesn't match, so the v3 plugins run withcompatibilityVersion: 4.meta.extensionbecomesmd: the edit link breaks, and RSS dates and page history go empty.contentfromserver/content.ts: the app and the server both auto-import acontent, and typed routes makenuxt typecheckresolve the client one.live-commitskey in the Runtime Cache, so two preview deployments on different branches can serve each other's commit for up tomaxAge.packandconsumerfail withERR_PNPM_NO_MATCHING_VERSIONuntil@nuxt/contentv4 is released./tree/<production branch>follows a push within 10 minutes?debug=searchlogs are goneELI5
The site used to carry its own machinery to decide which version of the docs to show and to search it in the browser. Nuxt Content does both now. When someone pushes a change, the site still updates in seconds, refreshes only the pages that changed, and search follows.
🤖 Generated with Amp, reviewed by @larbish before opening.