-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Implement legacy collections using glob #11976
base: next
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 505b426 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
!preview legacy-collections |
!preview legacy-collections |
- The `layout` field is not supported in Markdown | ||
- Experimental content collection cache is not supported | ||
- Sort order of generated collections is non-deterministic and platform-dependent. | ||
- `image().refine()` is not supported |
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.
Is this not supported in content layer in general?
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.
No. It's one of the things I missed. It'll be tough to do, because of the fact we don't transform it into an object until runtime.
Changes
Breaking change to legacy content collections, to be merged after 5.0 beta release.
Implements legacy content and data collections using
glob()
loader. By default, collections that use the the old types (content or data) are now implemented using the glob loader, with extra backward-compat handling. This includes any collection without aloader
defined.Any legacy content collections are handled like this:
glob
loader collection is defined, with patterns that match the previous handling (matchessrc/content/<collection name>/**/*.md
and other content extensions depending on installed integrations, with underscore-prefixed files and folders ignored)slug
field is added with the same format as beforerender()
method is added to the entry, so they can be called usingentry.render()
getEntryBySlug
is supportedLegacy data collections are handled like this:
glob
loader collection is defined, with patterns that match the previous handling (matchessrc/content/<collection name>/**/*{.json,.yaml}
and other data extensions, with underscore-prefixed files and folders ignored)getDataEntryById
is supportedWhile these emulate most of the features of legacy collections, they have these differences:
config.ts
. For legacy collections these can just be empty declarations: e.g.const blog = defineCollection({})
. Removing implicit collections means that we can allow content layer collections insrc/content
.layout
field is not supported in Markdownimage().refine()
is not supportedgetEntry
is typed asstring
, rather than having types for every entry.A new config flag
legacy.legacyContentCollections
is added for users that need the old behavior. When set, collections insrc/content
are processed in the same way as before rather than being implemented with glob - including implicit collections. When set, content layer collections are forbidden insrc/content
, and will fail a build if defined.Testing
Lots of tests have been updated. Where possible they use the new implementation, but when they need to test unsupported features then they have the legacy flag applied.
Docs