mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
import {defineDocumentType, makeSource} from "contentlayer/source-files";
|
|
import remarkGfm from "remark-gfm";
|
|
import rehypeSlug from "rehype-slug";
|
|
import {visit} from "unist-util-visit";
|
|
|
|
export const Doc = defineDocumentType(() => ({
|
|
name: "Doc",
|
|
filePathPattern: `docs/**/*.mdx`,
|
|
contentType: "mdx",
|
|
fields: {
|
|
title: {type: "string", required: true},
|
|
description: {type: "string", required: false},
|
|
date: {type: "date", required: false},
|
|
},
|
|
computedFields: {
|
|
slug: {
|
|
type: "string",
|
|
resolve: (doc) => `/${doc._raw.flattenedPath}`,
|
|
},
|
|
slugAsParams: {
|
|
type: "string",
|
|
resolve: (doc) => doc._raw.flattenedPath.split("/").slice(1).join("/"),
|
|
},
|
|
url: {type: "string", resolve: (doc) => `/${doc._raw.flattenedPath}`},
|
|
},
|
|
}));
|
|
|
|
export default makeSource({
|
|
contentDirPath: "./content",
|
|
documentTypes: [Doc],
|
|
mdx: {
|
|
remarkPlugins: [remarkGfm],
|
|
rehypePlugins: [
|
|
rehypeSlug,
|
|
() => (tree) => {
|
|
visit(tree, "element", (node) => {
|
|
if (node.tagName === "code" && node.data && node.data.meta) {
|
|
node.properties.meta = node.data.meta;
|
|
}
|
|
});
|
|
},
|
|
],
|
|
},
|
|
});
|