Closed twodft closed 4 weeks ago
Hello @twodft. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro
will be closed if they have no activity within 3 days.
I was able to make a reproduction of the issue, for my case whenever I set a non-empty array of reference as default in the zod schema it will give such an error:
https://stackblitz.com/edit/github-xzn8au?file=src%2Fcontent%2Fconfig.ts
Changes from the blog example:
Enable in astro.config.mjs
experimental: {
contentIntellisense: true,
},
Changed config.ts in content dir:
import { defineCollection, reference, z } from 'astro:content';
const blogCollection = defineCollection({
type: 'content',
schema: z.object({
// relatedArticles: reference('blog'), // WORKS
// relatedArticles: z.array(reference('blog')), // WORKS
// relatedArticles: z.array(z.string()).default([]), // WORKS
// relatedArticles: z.array(z.string()).default(['blog']), // WORKS
// relatedArticles: z.array(reference('blog')).default([]), // WORKS
relatedArticles: z.array(reference('blog')).default(['asdf']), // DOSEN'T WORK
}),
});
export const collections = {
blog: blogCollection,
};
Then regenerate the json schema by running astro sync
or the dev server
~/projects/xoriwwrxjz.github 8s
❯ npm run astro sync
> @example/blog@0.0.1 astro
> astro sync
14:47:51 [WARN] [content] An error was encountered while creating the JSON schema for the "blog" collection. Proceeding without it. Error: Error: Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
After enabling experimental.contentIntellisense in my Astro configuration (astro.config.mjs) and the corresponding setting in VS Code, I'm still encountering errors related to JSON schema creation for my content collections. The following warning messages are displayed in the terminal:
What's the expected result?
Astro should be able to generate the JSON schemas for all my content collections without any errors.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-xzn8au?file=src%2Fcontent%2Fconfig.ts
Participation