-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontentlayer.config.js
More file actions
37 lines (34 loc) · 1.2 KB
/
contentlayer.config.js
File metadata and controls
37 lines (34 loc) · 1.2 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
import { defineDocumentType, makeSource } from 'contentlayer/source-files';
import rehypeKatex from 'rehype-katex';
import remarkGfm from 'remark-gfm'; // to render tables (remark-gfm to be 2.0.0 and not higher - thi sis in pnpm-lock.yaml)
import remarkMath from 'remark-math';
import rehypeEnsureProps from './lib/rehypeEnsureProps.js';
// This tells Contentlayer/MDX to use the React JSX runtime (for blog)
process.env.NODE_ENV = 'production' // or 'production' during builds
process.env.CONTENTLAYER_CLI = 'next'
export const Blog = defineDocumentType(() => ({
name: 'Blog',
filePathPattern: `blog/*.mdx`,
contentType: 'mdx',
bodyType: 'mdx', // compiled component + code + html
fields: {
title: { type: 'string', required: true },
date: { type: 'date', required: true },
summary: { type: 'string' },
},
computedFields: {
slug: {
type: 'string',
resolve: (doc) =>
doc._raw.sourceFileName.replace(/\.mdx?$/, ''),
},
},
}))
export default makeSource({
contentDirPath: 'content',
documentTypes: [Blog],
mdx: {
remarkPlugins: [remarkMath, remarkGfm], // tables and equations
rehypePlugins: [rehypeEnsureProps, rehypeKatex],
},
})