Hello,
I'm working to build a blog with mutiple collections long story short:
I have this folder structure:
works/*/index.mdx
const works = defineCollection({
loader: glob({
pattern: "*.{md,mdx}",
base: ".src/content/works"}),
schema: ({ image }) => z.object({
state: z.string().optional(),
client: z.string().optional(),
title: z.string().optional(),
works: z.array(z.string()).optional(),
year: z.number().optional(),
summary: z.string().optional(),
headerImage: z.union([image(), z.string()]).optional(),
headerAlt: z.string().optional(),
images: z.array(
z.object({
src: z.union([image(), z.string()]),
alt: z.string().optional(),
})
).optional(),
gallery: z.array( // Add gallery support
z.object({
src: z.union([image(), z.string()]),
alt: z.string().optional(),
})
).optional(),
}),
});
and i call it using:
const works = (await getCollection('works'))
.sort((a, b) => b.data.year - a.data.year);
{works.map((work) => (
<a href={`/works/${work.id}/`}>
work.id is retrieving works/* /index.mdx all the time not works/*/ and the [slug].astro is working.
I'm a bit lost