34 lines
854 B
TypeScript
34 lines
854 B
TypeScript
import { defineDocumentType, makeSource } from 'contentlayer/source-files'
|
|
import rehypeAutolink from 'rehype-autolink-headings'
|
|
import rehypeSlug from 'rehype-slug'
|
|
import remarkGfm from 'remark-gfm'
|
|
|
|
export const Doc = defineDocumentType(() => ({
|
|
name: 'Doc',
|
|
filePathPattern: `**/*.md`,
|
|
contentType: 'markdown',
|
|
fields: {
|
|
title: { type: 'string', required: true },
|
|
order: { type: 'number', required: false },
|
|
},
|
|
computedFields: {
|
|
slug: {
|
|
type: 'string',
|
|
resolve: (doc) => doc._raw.flattenedPath,
|
|
},
|
|
url: {
|
|
type: 'string',
|
|
resolve: (doc) => `/${doc._raw.flattenedPath}`,
|
|
},
|
|
},
|
|
}))
|
|
|
|
export default makeSource({
|
|
contentDirPath: 'content',
|
|
documentTypes: [Doc],
|
|
markdown: {
|
|
remarkPlugins: [remarkGfm],
|
|
rehypePlugins: [rehypeSlug, [rehypeAutolink, { behavior: 'wrap' }]],
|
|
},
|
|
})
|