Open History to see the last commit
1import { defineCollection, defineConfig } from "@content-collections/core";
2import { z } from "zod";
3
4const posts = defineCollection({
5 name: "posts",
6 directory: "content/posts",
7 include: "**/*.md",
8 schema: z.object({
9 title: z.string(),
10 summary: z.string(),
11 categories: z.array(z.string()),
12 slug: z.string().optional(),
13 image: z.string(),
14 date: z.string(),
15 }),
16 transform: async (doc) => {
17 return {
18 ...doc,
19 slug: doc.title
20 .toLowerCase()
21 .replace(".md", "")
22 .replace(/[^\w-]+/g, "_"),
23 };
24 },
25});
26
27export default defineConfig({
28 collections: [posts],
29});