-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
support for legacy content collections removed #12376
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
base: v6
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for astro-docs-2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
|
||
<SourcePR number="14407" title="fix: remove legacy content collections"/> | ||
|
||
In Astro 5.x, it was still possible to use [the Content Collections API first introduced in Astro v2.0](https://astro.build/blog/introducing-content-collections/), either through a `legacy` configuration flag or via built-in backwards compatibility. These methods allowed you to upgrade to Astro v5 even if you were not yet ready or able to update your content collections to the new Content Layer API. |
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.
I don't think we're uisng the "content layer" terminology externally, are we?
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.
We do have it scattered around the content collections page, but we can choose to remove that now that a) there's absolutely no need to distinguish between legacy anymore and b) we will have live collections, so probably need some repositioning anyway.
It might still be helpful here and there in the upgrade guide, when the phrase was in use for v5? But I think we can for sure now remove it from our regular documentation for v6.
|
||
In Astro 5.x, it was still possible to use [the Content Collections API first introduced in Astro v2.0](https://astro.build/blog/introducing-content-collections/), either through a `legacy` configuration flag or via built-in backwards compatibility. These methods allowed you to upgrade to Astro v5 even if you were not yet ready or able to update your content collections to the new Content Layer API. | ||
|
||
**Astro v6.0 removes this previously deprecated Content Collections API support entirely, including the `legacy.collections` flag.** All content collections must now use the Content Layer API introduced in Astro v5.0 that powers all content collections. No backwards compatibility support is available. |
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.
**Astro v6.0 removes this previously deprecated Content Collections API support entirely, including the `legacy.collections` flag.** All content collections must now use the Content Layer API introduced in Astro v5.0 that powers all content collections. No backwards compatibility support is available. | |
**Astro v6.0 removes this previously deprecated legacy content collections API support entirely, including the `legacy.collections` flag.** All content collections must now use the new API introduced in Astro v5.0 that powers all content collections. No backwards compatibility support is available. |
|
||
If you have content collections errors after upgrading to v6, use the following list to help you identify and upgrade any legacy features that may exist in your code. | ||
|
||
##### If you have... |
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.
We should add the error messages in here too
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.
Yes, this could be helpful, or at least the error code so someone can easily identify the details
to expand.
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.
Great idea! Would the implementation PR be a comprehensive list of all the ones they might encounter?
I'm seeing:
- 'LegacyContentConfigError'
- 'ContentCollectionMissingLoader'
- 'ContentCollectionInvalidType'
What we did for v5 was mock up the new errors / config in the v5 branch (duplicating what would be generated from the JSDoc), so we should probabably manually recreate those errors in this PR, too. If they end up not being identical, then a ci PR will be generated to align them.
Just copied the entire jsdoc from entries here for now
- @docs
- @message
- Example error message:
- Found legacy content config file in "src/content/config.ts". Please move this file to "src/content.config.ts" and ensure each collection has a loader defined.
- @description
- A legacy content config file was found. Move the file to
src/content.config.ts
and update any collection definitions if needed. - See the Astro 6 migration guide for more information.
*/
export const LegacyContentConfigError = {
name: 'LegacyContentConfigError',
title: 'Legacy content config file found.',
message: (filename: string) =>
Found legacy content config file in "${filename}". Please move this file to "src/content.config.${filename.split('.').at(-1)}" and ensure each collection has a loader defined.
,
hint: 'See https://docs.astro.build/en/guides/upgrade-to/v6/#removed-legacy-content-collections for more information on updating collections.',
} satisfies ErrorData;
/**
- @docs
- @message
- Example error message:
- Collections must have a
loader
defined. Check your collection definitions in your content config file. - @description
- A content collection is missing a
loader
definition. Make sure that each collection in your content config file has aloader
. - See the Content collections documentation for more information.
*/
export const ContentCollectionMissingLoader = {
name: 'ContentCollectionMissingLoader',
title: 'Content collection is missing a loader
definition.',
message: (file = 'your content config file') =>
Collections must have a \
loader` defined. Check your collection definitions in ${file}.`,
hint: 'See https://docs.astro.build/en/guides/content-collections/ for more information on content loaders and https://docs.astro.build/en/guides/upgrade-to/v6/#removed-legacy-content-collections for more information on migrating from legacy collections.',
} satisfies ErrorData;
/**
- @docs
- @message
- Example error message:
- Invalid collection type "data". Remove the type from your collection definition in your content config file.
- @description
- Content collections should no longer have a
type
field. Remove this field from your content config file. - See the Astro 6 migration guide for more information.
*/
export const ContentCollectionInvalidType = {
name: 'ContentCollectionInvalidType',
title: 'Content collection has an invalid type
field.',
message: (type: string, file = 'your content config file') =>
Invalid collection type "${type}". Remove the type from your collection definition in ${file}.
,
hint: 'See https://docs.astro.build/en/guides/upgrade-to/v6/#removed-legacy-content-collections for more information on migrating from legacy collections.',
} satisfies ErrorData;
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.
There are also some places where we just log a warning rather than throwing an error:
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.
I could add a more searchable name there too.
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.
A small nit, otherwise I think this format looks great and makes sense!
|
||
In Astro 5.x, it was still possible to use [the Content Collections API first introduced in Astro v2.0](https://astro.build/blog/introducing-content-collections/), either through a `legacy` configuration flag or via built-in backwards compatibility. These methods allowed you to upgrade to Astro v5 even if you were not yet ready or able to update your content collections to the new Content Layer API. | ||
|
||
**Astro v6.0 removes this previously deprecated Content Collections API support entirely, including the `legacy.collections` flag.** All content collections must now use the Content Layer API introduced in Astro v5.0 that powers all content collections. No backwards compatibility support is available. |
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.
**Astro v6.0 removes this previously deprecated Content Collections API support entirely, including the `legacy.collections` flag.** All content collections must now use the Content Layer API introduced in Astro v5.0 that powers all content collections. No backwards compatibility support is available. | |
**Astro v6.0 removes this previously deprecated Content Collections API support entirely, including the `legacy.collections` flag.** All content collections must now use [the Content Layer API introduced in Astro v5.0](https://astro.build/blog/content-layer-deep-dive/) that powers all content collections. No backwards compatibility support is available. |
For example, we could do this here, then use all the rest of your suggestions for just legacy/new. This link is probably more important than the 2.0 one, and we could even remove the other link in favour of just this one.
Co-authored-by: Matt Kane <[email protected]>
src/content/docs/en/reference/errors/content-collection-invalid-type.mdx
Outdated
Show resolved
Hide resolved
src/content/docs/en/reference/errors/content-collection-missing-loader.mdx
Outdated
Show resolved
Hide resolved
src/content/docs/en/reference/errors/legacy-content-config-error.mdx
Outdated
Show resolved
Hide resolved
src/content/docs/en/reference/errors/legacy-content-config-error.mdx
Outdated
Show resolved
Hide resolved
|
||
Astro v5.x included some automatic backwards compatibility to allow content collections to continue to work even if they had not been updated to use the new API. Therefore, your v5 collections may contain one or more legacy features that need updating to the newer API for v6, even if your project was previously error-free. | ||
|
||
If you have content collections errors after upgrading to v6, use the following list to help you identify and upgrade any legacy features that may exist in your code. |
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.
If you have content collections errors after upgrading to v6, use the following list to help you identify and upgrade any legacy features that may exist in your code. | |
If you have [content collections errors](/en/reference/error-reference/#content-collection-errors) after upgrading to v6, use the following list to help you identify and upgrade any legacy features that may exist in your code. |
The link exists, but I haven't bothered to put these individual errors on the index page. I don't know whether we need to explicitly include the 3 legacy errors here, or just point them to the content collections general set of errors.
This adds "Removed: content collections" to the v6 upgrade guide
Direct deploy preview: https://deploy-preview-12376--astro-docs-2.netlify.app/en/guides/upgrade-to/v6/#removed-legacy-content-collections
Implementation PR #14407
This PR should include
Notes:
astro:content
reference updated needed: v5 already only documents the newest API