-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontentlayer.config.ts
41 lines (39 loc) · 1.22 KB
/
contentlayer.config.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
import { defineDocumentType, makeSource } from 'contentlayer/source-files'
import rehypeSlug from 'rehype-slug'
import rehypePrettyCode, { type Options as RehypePrettyCodeOptions } from 'rehype-pretty-code'
import aylinTheme from './aylin.json'
export const Article = defineDocumentType(() => ({
name: 'Article',
filePathPattern: `**/*.mdx`,
contentType: 'mdx',
fields: {
title: { type: 'string', required: true },
date: { type: 'date', required: true },
color: { type: 'string', required: true },
featured: { type: 'boolean', required: false },
},
computedFields: {
url: {
type: 'string',
resolve: (article) => `/articles/${article._raw.flattenedPath}`,
},
},
}))
export default makeSource({
contentDirPath: 'writings',
documentTypes: [Article],
mdx: {
remarkPlugins: [],
rehypePlugins: [
rehypeSlug,
[
// @ts-expect-error These types are incompatible, check issue: https://github.com/atomiks/rehype-pretty-code/issues/127
rehypePrettyCode,
{
// @ts-expect-error The theme works fine, but for some reason the types are not compatible
theme: aylinTheme,
} satisfies RehypePrettyCodeOptions,
],
],
},
})