Hello there,
I'm trying to use the new content feature in v5.
I created my collection :
import { defineCollection, z } from 'astro:content';
import { glob } from 'astro/loaders';
const pagesCollection = defineCollection({
loader: glob({ pattern: "**/*.md", base: "./src/content/pages" }),
schema: ({ image }) => {
const Hero = z.object({
type: z.literal("hero"),
title: z.string(),
image: image(),
text: z.string(),
cta: z.object({
target: z.boolean(),
title: z.string(),
link: z.string(),
}).partial(),
});
return z.object({
title: z.string(),
content: z.array(z.discriminatedUnion("type", [
Hero
])),
});
},
});
export const collections = { pagesCollection };
here's my page created
---
title: Ma super page
content:
- type: header
title: Mon super hero
text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer luctus
non nisl in vestibulum. Suspendisse nisl arcu, rutrum sit amet auctor vel,
rutrum viverra arcu. Maecenas dictum maximus ante, vestibulum suscipit
lacus sodales ut. Mauris sit amet venenatis lectus, vitae rutrum neque. In
euismod non massa eu malesuada
cta:
target: false
title: Test
link: test
image: src/assets/content/images/site.jpg
---
When i'm trying to get it, an error pop : "Could not find requested image src/assets/content/images/site.jpg. Does it exist?"
and it actually exist, see capture.
Is there any config I missed ?
Thanks in advance,