generated from Kamigami55/nextjs-tailwind-contentlayer-blog-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contentlayer.config.ts
62 lines (59 loc) · 1.44 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
import rehypeCodeTitles from 'rehype-code-titles';
import rehypePrism from 'rehype-prism-plus';
import rehypeSlug from 'rehype-slug';
import { DEFAULT_LOCALE, LOCALES } from './src/configs/i18nConfigs';
import { defineDocumentType, makeSource } from './src/lib/contentLayerAdapter';
import imageMetadata from './src/plugins/imageMetadata';
export const Post = defineDocumentType(() => ({
name: 'Post',
filePathPattern: `content/posts/**/*.mdx`,
contentType: 'mdx',
fields: {
title: {
type: 'string',
required: true,
},
description: {
type: 'string',
required: true,
},
slug: {
type: 'string',
required: true,
},
date: {
type: 'date',
required: true,
},
socialImage: {
type: 'string',
},
language: {
type: 'enum',
options: LOCALES,
default: DEFAULT_LOCALE,
},
redirectFrom: {
type: 'list',
of: { type: 'string' },
},
},
computedFields: {
path: {
type: 'string',
resolve: (post) => `/posts/${post.slug}`,
},
},
}));
export default makeSource({
contentDirPath: 'content',
documentTypes: [Post],
mdx: {
rehypePlugins: [
rehypeSlug, // For generating slugs for headings
rehypeCodeTitles, // For adding titles to code blocks
[rehypePrism, { ignoreMissing: true }], // For code syntax highlighting
imageMetadata, // For adding image metadata (width, height)
],
},
});