diff options
Diffstat (limited to 'examples/starlog/src/content.config.ts')
-rw-r--r-- | examples/starlog/src/content.config.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/examples/starlog/src/content.config.ts b/examples/starlog/src/content.config.ts new file mode 100644 index 000000000..26986525a --- /dev/null +++ b/examples/starlog/src/content.config.ts @@ -0,0 +1,22 @@ +import { glob } from 'astro/loaders'; +import { defineCollection, z } from 'astro:content'; + +const releases = defineCollection({ + // Load Markdown files in the src/content/releases directory. + loader: glob({ base: './src/content/releases', pattern: '**/*.md' }), + // Type-check frontmatter using a schema + schema: ({ image }) => + z.object({ + title: z.string(), + description: z.string(), + versionNumber: z.string(), + image: z.object({ + src: image(), + alt: z.string(), + }), + // Transform string to Date object + date: z.date({ coerce: true }), + }), +}); + +export const collections = { releases }; |