Repository navigation
Follow Nuxt Content collections for routes and variable schemas - #52
Merged
Merged
Conversation
Route links now follow the page collections of content.config.ts as Nuxt Content 3.16 builds routes: each source's files below cwd that match include and not exclude, routed as prefix (by default the static part of include) plus the path below that static part. A path in a page's front matter overrides the route. Without collections the default content/ routing is unchanged. Collection schemas held in variables are resolved, with .extend(), .merge(), .omit(), .pick() and field-keeping calls such as .passthrough(); imported schemas and other calls stay unknown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KGGeqcwjamvMDTrazMJWkz
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.
What and why
Reported with a real
content.config.ts. It has four page collections (pages_en,pages_cs,threats_en,threats_cs), each withsource: { include, prefix }, and schemas held in variables (pageSchema.passthrough().extend({...}),threatSchema.extend({...})).I reproduced that project in a test. File detection works on master: every file in all four collections is Comark and matches its own collection. Two real gaps showed up:
/threats/phishing,/cs/hrozby/phishing,/aboutand/cs/o-nasdidn't resolve; only the raw directory paths did.schemaKnown = falsewith no fields, so the Nuxt Studio style couldn't apply Studio's defaults (toc: false,icon,category).Changes
ComarkContentRoutes), checked against@nuxt/content3.16.2 (defineLocalSource,parseSourceBase,describeId,generatePath):content.config.*, routes come from the page collections: the files below each source'scwdthat matchincludeand notexclude.prefixfollowed by the file's path below the static part ofinclude. Without aprefix, the static part itself is used.indexand.draftare dropped, and segments are slugified.path:overrides the route. This also applies with the default routing.content/routing is unchanged.ComarkCollections.resolveSchema):const x = z.object({...})(also with a type annotation, over several lines) is followed..extend(),.merge()and.safeExtend()add or replace fields; a replaced field keeps its place..omit()and.pick()drop fields..passthrough(),.partial(),.describe()and similar calls keep the fields..transform(),.and()) stay unknown.ComarkCollections.Sourcenow carriesprefix,fixedandroutePrefix.How it was tested
ComarkCollectionRoutesTest(new): prefixes (/,/cs,/threats), the default prefix with slugified segments, a front matterpathoverride,exclude, data collections, andcollectionRoutecases.ComarkCollectionsTest: schemas in variables (extend / merge / omit / pick / partial, replaced field position, imported → unknown), spread and transform → unknown, and source prefix and fixed part. The old assertion that "a schema in a variable is unknown" now expects the resolved schema.ComarkRouteReferenceTest(default routing) is unchanged and passes../gradlew test: 903 tests, 0 failures.Generated by Claude Code