2023-07-03 18:29:03 +08:00
2023-07-03 18:27:55 +08:00
2023-07-05 16:33:32 +08:00
2023-07-03 18:27:55 +08:00
2023-07-05 16:15:47 +08:00
2023-07-03 18:27:55 +08:00
2023-07-03 18:27:55 +08:00

Configurations

ContentLayer

We recommend rehype-pretty-code, remark-gfm and rehype-slug.

import { defineDocumentType, makeSource } from "contentlayer/source-files";
import rehypePrettycode from "rehype-pretty-code";
import remarkGfm from "remark-gfm";
import rehypeSlug from "rehype-slug";

const Docs = defineDocumentType(() => ({
    name: "Docs",
    filePathPattern: `docs/**/*.mdx`,
    contentType: "mdx",
    fields: {
        title: {
            type: "string",
            description: "The title of the document",
            required: true,
        },
        description: {
            type: "string",
            description: "The description of the document",
            required: false,
        },
    },
    computedFields: {
        url: {
            type: "string",
            resolve: (post) => {
                return "/" + post._raw.flattenedPath;
            },
        },
        slug: {
            type: "string",
            resolve: (post) => {
                return post._raw.flattenedPath.split("/").slice(1).join("/");
            },
        },
    },
}));

const Meta = defineDocumentType(() => ({
    name: "Meta",
    filePathPattern: `docs/**/meta.json`,
    contentType: "data",
    fields: {
        title: {
            type: "string",
            description: "The title of the folder",
            required: false,
        },
        pages: {
            type: "list",
            of: {
                type: "string",
            },
            description: "Pages of the folder",
            default: [],
        },
    },
    computedFields: {
        url: {
            type: "string",
            resolve: (post) => "/" + post._raw.sourceFileDir,
        },
    },
}));

export default makeSource({
    contentDirPath: "content",
    documentTypes: [Docs, Meta],
    mdx: {
        rehypePlugins: [
            [
                rehypePrettycode,
                {
                    theme: "css-variables",
                },
            ],
            rehypeSlug,
        ],
        remarkPlugins: [remarkGfm],
    },
});
S
Description
No description provided
Readme MIT
470 MiB
Languages
TypeScript 41.7%
MDX 34.6%
JavaScript 20.5%
CSS 1.3%
XSLT 0.7%
Other 1%