generated from yehezkielgunawan/next15-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent-collections.ts
More file actions
109 lines (103 loc) · 2.76 KB
/
content-collections.ts
File metadata and controls
109 lines (103 loc) · 2.76 KB
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
import { defineCollection, defineConfig } from "@content-collections/core";
import { compileMDX } from "@content-collections/mdx";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import rehypeRaw from "rehype-raw";
import rehypeSlug from "rehype-slug";
import remarkGfm from "remark-gfm";
import { z } from "zod";
/**
* Mermaid code block language variants (handled by MermaidInit client-side):
* ```mermaid -> default responsive behavior
* ```mermaid-overflow -> always scroll horizontally
* ```mermaid-fit -> always fit to container
*
* The language variants are preserved in the rendered HTML as class names
* (e.g., "language-mermaid-overflow") which the MermaidInit component reads
* to apply the correct CSS styling.
*/
const projects = defineCollection({
name: "projects",
directory: "content/projects",
include: "**/*.mdx",
schema: z.object({
name: z.string(),
description: z.string(),
url: z.string(),
projectIcon: z.string(),
projectHero: z.string(),
stacks: z.array(z.string()),
isFeatured: z.boolean(),
date: z.string(),
content: z.string(),
}),
transform: (document) => {
const { content: _, ...metadata } = document;
return metadata;
},
});
const workExperiences = defineCollection({
name: "workExperiences",
directory: "content/work-experiences",
include: "**/*.mdx",
schema: z.object({
title: z.string(),
company: z.string(),
startDate: z.string(),
endDate: z.string().optional(),
content: z.string(),
}),
transform: (document) => {
const { content: _, ...metadata } = document;
return metadata;
},
});
const blogs = defineCollection({
name: "blogs",
directory: "content/blogs",
include: "**/*.mdx",
schema: z.object({
title: z.string(),
summary: z.string(),
coverImg: z.string(),
date: z.string(),
category: z.string(),
content: z.string(),
}),
transform: async (document, context) => {
const mdx = await compileMDX(context, document, {
rehypePlugins: [rehypeAutolinkHeadings, rehypeSlug, rehypeRaw],
remarkPlugins: [remarkGfm],
});
const { content: _, ...metadata } = document;
return {
...metadata,
mdx,
};
},
});
const quickNotes = defineCollection({
name: "quickNotes",
directory: "content/quick-notes",
include: "**/*.mdx",
schema: z.object({
title: z.string(),
subtitle: z.string(),
date: z.string(),
tags: z.array(z.string()),
content: z.string(),
}),
transform: async (document, context) => {
const mdx = await compileMDX(context, document, {
rehypePlugins: [rehypeAutolinkHeadings, rehypeSlug, rehypeRaw],
remarkPlugins: [remarkGfm],
});
const { content: _, ...metadata } = document;
return {
...metadata,
mdx,
};
},
});
export default defineConfig({
collections: [projects, workExperiences, blogs, quickNotes],
});