This repository has been archived by the owner on Dec 24, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcontent-collections.ts
122 lines (114 loc) · 3.01 KB
/
content-collections.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { defineCollection, defineConfig } from '@content-collections/core';
import readingTime from 'reading-time';
const projects = defineCollection({
name: 'projects',
directory: 'content/projects',
include: '**/*.md',
schema: (z) => ({
title: z.string(),
description: z.string(),
published: z.boolean().catch(true),
/** will be shown at home */
highlight: z.boolean().optional(),
/** shown at project list frontpage */
featured: z.boolean().optional(),
sznmApps: z.boolean().optional(),
stacks: z.array(z.string()).optional(),
date: z.string(),
projectLink: z.string().optional(),
repoLink: z.string().optional(),
appStoreLink: z.string().optional(),
playStoreLink: z.string().optional(),
icon: z.string().optional(),
thumbnail: z.string().optional(),
thumbnailDark: z.string().optional(),
projectType: z.string().optional(),
id: z.string().optional(),
}),
transform: (doc) => ({
...doc,
id: doc._meta.fileName.replace(/\.md$|\.mdx$/, ''),
}),
});
const posts = defineCollection({
name: 'posts',
directory: 'content/posts',
include: '**/*.md',
schema: (z) => ({
title: z.string(),
date: z.string(),
cover: z.string(),
thumbnail: z.string().optional(),
description: z.string().optional(),
legacyID: z.string().optional(),
published: z.boolean().catch(true),
tags: z.array(z.string()),
readTime: z
.object({
text: z.string(),
minutes: z.string(),
time: z.string(),
words: z.string(),
})
.optional(),
cover_image: z.string().optional(),
id: z.string().optional(),
}),
transform: (doc) => ({
...doc,
readTime: Object(readingTime(doc.content)),
id: doc._meta.fileName.replace(/\.md$|\.mdx$/, ''),
}),
});
type NoteCollectionDefinitionParams = {
name: string;
directory: string;
};
const noteCollectionDefinition = ({
name,
directory,
}: NoteCollectionDefinitionParams) =>
defineCollection({
name,
directory,
include: '**/*.md',
schema: (z) => ({
title: z.string(),
description: z.string(),
published: z.boolean().catch(true),
date: z.string(),
tags: z.array(z.string()),
id: z.string().optional(),
}),
transform: (doc) => ({
...doc,
id: doc._meta.fileName.replace(/\.md$|\.mdx$/, ''),
}),
});
const notes = noteCollectionDefinition({
name: 'notes',
directory: 'content/notes',
});
const todayILearns = noteCollectionDefinition({
name: 'todayILearns',
directory: 'content/til',
});
const testimonies = defineCollection({
name: 'testimonies',
directory: 'content/testimonies',
include: '**/*.md',
schema: (z) => ({
name: z.string(),
title: z.string(),
year: z.string(),
linkedin: z.string().optional(),
id: z.string().optional(),
}),
transform: (doc) => ({
...doc,
id: doc._meta.fileName.replace(/\.md$|\.mdx$/, ''),
}),
});
export default defineConfig({
collections: [projects, posts, notes, todayILearns, testimonies],
});