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

content-collections.ts

56 lines1.2 KB

1import { defineCollection, defineConfig } from '@content-collections/core'
2import { z } from 'zod'
3​
4const speakers = defineCollection({
5 name: 'speakers',
6 directory: 'content/speakers',
7 include: '**/*.md',
8 schema: z.object({
9 name: z.string(),
10 title: z.string(),
11 specialty: z.string(),
12 restaurant: z.string(),
13 location: z.string(),
14 headshot: z.string(),
15 awards: z.array(z.string()).optional(),
16 content: z.string(),
17 }),
18 transform: async (doc) => {
19 return {
20 ...doc,
21 slug: doc.name
22 .toLowerCase()
23 .replace(/[^\w-]+/g, '-')
24 .replace(/-+/g, '-')
25 .replace(/^-|-$/g, ''),
26 }
27 },
28})
29​
30const talks = defineCollection({
31 name: 'talks',
32 directory: 'content/talks',
33 include: '**/*.md',
34 schema: z.object({
35 title: z.string(),
36 speaker: z.string(),
37 duration: z.string(),
38 image: z.string(),
39 topics: z.array(z.string()),
40 content: z.string(),
41 }),
42 transform: async (doc) => {
43 return {
44 ...doc,
45 slug: doc.title
46 .toLowerCase()
47 .replace(/[^\w-]+/g, '-')
48 .replace(/-+/g, '-')
49 .replace(/^-|-$/g, ''),
50 }
51 },
52})
53​
54export default defineConfig({
55 collections: [speakers, talks],
56})