-
Notifications
You must be signed in to change notification settings - Fork 2
/
contentlayer.config.js
executable file
·70 lines (64 loc) · 2.01 KB
/
contentlayer.config.js
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
import { defineDocumentType, makeSource } from 'contentlayer/source-files'
import remarkGfm from 'remark-gfm'
import rehypePrism from '@mapbox/rehype-prism'
import rehypePrettyCode from 'rehype-pretty-code'
const computedFields = {
url: {
type: 'string',
resolve: (doc) => `/${doc._raw.flattenedPath}`,
},
slug: {
type: 'string',
resolve: (doc) => `${doc._raw.sourceFileName.replace('.mdx', '')}`,
},
}
/** @type {import('rehype-pretty-code').Options} */
const options = {
theme: 'nord',
}
export const Post = defineDocumentType(() => ({
name: 'Post',
filePathPattern: `blog/**/*.mdx`,
contentType: 'mdx',
fields: {
title: { type: 'string', required: true },
date: { type: 'date', required: true },
category: { type: 'string', required: true },
image: { type: 'string', required: true },
description: { type: 'string', required: true },
timeToRead: { type: 'number', required: true }, // in minutes
},
computedFields,
}))
export const CaseStudy = defineDocumentType(() => ({
name: 'CaseStudy',
filePathPattern: `work/**/*.mdx`,
contentType: 'mdx',
fields: {
title: { type: 'string', required: true },
subtitle: { type: 'string', required: true },
date: { type: 'date', required: true },
tags: {
type: 'list',
of: { type: 'string' },
},
thumbnail: { type: 'string', required: true },
coverImage: { type: 'string', required: true },
// images: { type: 'list', of: { type: 'string' } },
projectURL: { type: 'string', required: true },
githubLink: { type: 'string', required: true },
description: { type: 'string', required: true },
projectDuration: { type: 'string', required: true },
client: { type: 'json', required: true },
// testimonial: { type: 'json', required: true },
},
computedFields,
}))
export default makeSource({
contentDirPath: 'src/content',
documentTypes: [Post, CaseStudy],
mdx: {
remarkPlugins: [remarkGfm],
rehypePlugins: [rehypePrism, [rehypePrettyCode, options]],
},
})