Skip to content
Source
Sign inSign up
TanStack/cli
Open History to see the last commit

content-collections.ts

28 lines608 Bytes

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