Compare commits

...

5 Commits

Author SHA1 Message Date
Florian Lefebvre
551dea964b Apply suggestion from @florian-lefebvre 2025-12-03 17:33:52 +01:00
Florian Lefebvre
0c1b5589cb Apply suggestion from @florian-lefebvre 2025-12-03 17:15:15 +01:00
Florian Lefebvre
591eeb84ea Update .changeset/fresh-rocks-sing.md
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
2025-12-03 17:14:22 +01:00
Florian Lefebvre
1e906b2e28 Update packages/astro/src/content/utils.ts
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
2025-12-03 17:14:01 +01:00
Florian Lefebvre
ad72298654 Apply suggestions from code review 2025-12-03 14:33:39 +01:00
6 changed files with 6 additions and 6 deletions

View File

@@ -2,4 +2,4 @@
'astro': major
---
Removes the ability for content loaders schemas to be functions and adds a new equivalent `createSchema()` property (Loader API) - ([v6 upgrade guidance](https://deploy-preview-12322--astro-docs-2.netlify.app/en/guides/upgrade-to/v6/TODO:))
Removes the option to define dynamic schemas in content loaders as functions and adds a new equivalent `createSchema()` property (Loader API) - ([v6 upgrade guidance](https://deploy-preview-12322--astro-docs-2.netlify.app/en/guides/upgrade-to/v6/TODO:))

View File

@@ -399,7 +399,7 @@ async function typeForCollection<T extends keyof ContentConfig['collections']>(
}
const base = `loaders/${collectionKey.slice(1, -1)}`;
return {
type: `import("./${base}.js").Collection`,
type: `import("./${base}.js").Entry`,
injectedType: {
filename: `${base}.ts`,
content: result.types,

View File

@@ -66,7 +66,7 @@ const collectionConfigParser = z.union([
.transform((v) => {
if (typeof v === 'function') {
console.warn(
`Since Astro 6, a loader schema cannot be a function. It is ignored and will break in a future major. Report it to the loader author or check the docs: TODO:`,
`Your loader's schema is defined using a function. This is no longer supported and the schema will be ignored. Please update your loader to use the \`createSchema()\` utility instead, or report this to the loader author. In a future major version, this will cause the loader to break entirely.`,
);
return undefined;
}

View File

@@ -197,7 +197,7 @@ describe('astro sync', () => {
await fixture.load('./fixtures/content-layer-loader-schema-function/');
fixture.clean();
await fixture.whenSyncing();
fixture.thenWarnLogsInclude('Since Astro 6, a loader schema cannot be a function.');
fixture.thenWarnLogsInclude("Your loader's schema is defined using a function.");
});
});

View File

@@ -234,7 +234,7 @@ const increment = defineCollection({
refreshContextData: z.record(z.unknown()).optional(),
slug: z.string().optional(),
}),
types: /* ts */`export interface Collection {
types: /* ts */`export interface Entry {
lastValue: number;
lastUpdated: Date;
refreshContextData?: Record<string, unknown> | undefined;

View File

@@ -41,7 +41,7 @@ export function loader(config:PostLoaderConfig): Loader {
userId: z.number(),
id: z.number(),
}),
types: /* ts */`export interface Collection {
types: /* ts */`export interface Entry {
title: string;
body: string;
userId: number;