summaryrefslogtreecommitdiff
path: root/examples/blog/src/content.config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'examples/blog/src/content.config.ts')
-rw-r--r--examples/blog/src/content.config.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/blog/src/content.config.ts b/examples/blog/src/content.config.ts
new file mode 100644
index 000000000..7d92b1a3b
--- /dev/null
+++ b/examples/blog/src/content.config.ts
@@ -0,0 +1,18 @@
+import { glob } from 'astro/loaders';
+import { defineCollection, z } from 'astro:content';
+
+const blog = defineCollection({
+ // Load Markdown and MDX files in the `src/content/blog/` directory.
+ loader: glob({ base: './src/content/blog', pattern: '**/*.{md,mdx}' }),
+ // Type-check frontmatter using a schema
+ schema: z.object({
+ title: z.string(),
+ description: z.string(),
+ // Transform string to Date object
+ pubDate: z.coerce.date(),
+ updatedDate: z.coerce.date().optional(),
+ heroImage: z.string().optional(),
+ }),
+});
+
+export const collections = { blog };