41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import "dotenv/config"
|
|
|
|
import { defineDocumentType, makeSource } from "contentlayer/source-files"
|
|
import { rehypeComponent } from "./src/lib/rehype-component"
|
|
import rehypeSlug from "rehype-slug"
|
|
|
|
export const Doc = defineDocumentType(() => ({
|
|
name: "Doc",
|
|
filePathPattern: `docs/**/*.mdx`,
|
|
contentType: "mdx",
|
|
fields: {
|
|
title: { type: "string", required: true },
|
|
description: { type: "string", required: true },
|
|
component: { type: "boolean", required: false, default: false },
|
|
},
|
|
computedFields: {
|
|
slug: {
|
|
type: "string",
|
|
resolve: (doc) => `/ui/${doc._raw.flattenedPath}`,
|
|
},
|
|
slugAsParams: {
|
|
type: "string",
|
|
resolve: (doc) => doc._raw.flattenedPath.split("/").slice(1).join("/"),
|
|
},
|
|
},
|
|
}))
|
|
|
|
export default makeSource({
|
|
contentDirPath: "./src/content",
|
|
documentTypes: [Doc],
|
|
mdx: {
|
|
rehypePlugins: [[rehypeComponent], [rehypeSlug]],
|
|
mdxOptions: (options) => {
|
|
return {
|
|
...options,
|
|
development: process.env.NODE_ENV === "development",
|
|
}
|
|
},
|
|
},
|
|
})
|