summaryrefslogtreecommitdiff
path: root/examples/with-content/src/content/config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'examples/with-content/src/content/config.ts')
-rw-r--r--examples/with-content/src/content/config.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/with-content/src/content/config.ts b/examples/with-content/src/content/config.ts
new file mode 100644
index 000000000..9d436060a
--- /dev/null
+++ b/examples/with-content/src/content/config.ts
@@ -0,0 +1,18 @@
+import { defineCollection, z } from 'astro:content';
+
+const blog = defineCollection({
+ // Type-check frontmatter using a schema
+ schema: {
+ title: z.string(),
+ description: z.string(),
+ // Transform string to Date object
+ pubDate: z.string().transform((str) => new Date(str)),
+ updatedDate: z
+ .string()
+ .optional()
+ .transform((str) => (str ? new Date(str) : undefined)),
+ heroImage: z.string().optional(),
+ },
+});
+
+export const collections = { blog };