generated from jintak0401/next-tailwind-pnpm-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontentlayer.config.ts
75 lines (70 loc) · 1.96 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
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
import {
ComputedFields,
defineDocumentType,
makeSource,
} from 'contentlayer/source-files';
import rehypePresetMinify from 'rehype-preset-minify';
import rehypePrismPlus from 'rehype-prism-plus';
import rehypeSlug from 'rehype-slug';
// Rehype packages
import remarkFootnotes from 'remark-footnotes';
// Remark packages
import remarkGfm from 'remark-gfm';
import remarkCodeTitles from './src/lib/remark/remark-code-title';
import remarkImgToJsx from './src/lib/remark/remark-img-to-jsx';
const computedFields: ComputedFields = {
slug: {
type: 'string',
resolve: (doc) => doc._raw.flattenedPath.replace(/^.+?(\/)/, ''),
},
};
export const Blog = defineDocumentType(() => ({
name: 'Blog',
filePathPattern: 'blog/**/*.mdx',
contentType: 'mdx',
fields: {
title: { type: 'string', required: true },
date: { type: 'date', required: true },
tags: { type: 'list', of: { type: 'string' } },
lastmod: { type: 'date' },
draft: { type: 'boolean' },
summary: { type: 'string' },
images: { type: 'list', of: { type: 'string' } },
layout: { type: 'string' },
series: { type: 'string' },
bibliography: { type: 'string' },
canonicalUrl: { type: 'string' },
},
computedFields,
}));
export const Project = defineDocumentType(() => ({
name: 'Project',
filePathPattern: 'project/**/*.mdx',
contentType: 'mdx',
fields: {
title: { type: 'string', required: true },
summary: { type: 'string' },
images: { type: 'list', of: { type: 'string' } },
layout: { type: 'string' },
canonicalUrl: { type: 'string' },
},
computedFields,
}));
export default makeSource({
contentDirPath: 'data',
documentTypes: [Blog, Project],
mdx: {
cwd: process.cwd(),
remarkPlugins: [
remarkGfm,
remarkCodeTitles,
[remarkFootnotes, { inlineNotes: true }],
remarkImgToJsx,
],
rehypePlugins: [
rehypeSlug,
[rehypePrismPlus, { ignoreMissing: true }],
rehypePresetMinify,
],
},
});