-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.mjs
More file actions
76 lines (72 loc) · 2.18 KB
/
next.config.mjs
File metadata and controls
76 lines (72 loc) · 2.18 KB
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
71
72
73
74
75
76
import remarkGfm from "remark-gfm"; // 请使用 3.0.1 如果使用 4.0.0 data undefined
import remarkFrontmatter from "remark-frontmatter";
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
import rehypeSlug from "rehype-slug";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import rehypeExtractToc from "@stefanprobst/rehype-extract-toc";
import rehypeExtractTocMdx from "@stefanprobst/rehype-extract-toc/mdx";
import rehypePrettyCode from "rehype-pretty-code";
import moonlightTheme from "./src/config/moonlight-ii.json" assert { type: "json" };
import createMDX from "@next/mdx";
// import { visit } from "unist-util-visit";
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
pageExtensions: ["js", "jsx", "mdx", "ts", "tsx"],
reactStrictMode: true,
// experimental: {
// mdxRs: true,
// },
};
/** @type {import('rehype-pretty-code').Options} */
const options = {
keepBackground: true,
// filterMetaString: (string) => string.replace(/filename="[^"]*"/, ""),
filterMetaString: (string) => string.replace(/filename/, "title"),
theme: {
dark: "github-dark-dimmed",
light: moonlightTheme,
},
defaultLang: {
block: "plaintext",
inline: "plaintext",
},
};
const withMDX = createMDX({
options: {
remarkPlugins: [
remarkGfm, // 不支持in code `code`
remarkFrontmatter,
remarkMdxFrontmatter,
],
rehypePlugins: [
rehypeSlug,
[
rehypeAutolinkHeadings,
{
behavior: "append",
properties: {
ariaHidden: true,
tabIndex: -1,
className: "hash-link",
},
},
],
rehypeExtractToc,
rehypeExtractTocMdx,
[rehypePrettyCode, options],
// () => (tree) => {
// visit(tree, "element", (node) => {
// if (node.tagName === "code" && node.data && node.data.meta) {
// // node.properties.meta = node.data.meta;
// console.log({ meta: node.data.meta });
// }
// });
// },
],
// 如果使用`MDXProvider`,请取消对以下行的注释。
// providerImportSource: "@mdx-js/react",
},
});
export default withMDX(nextConfig);