-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.mjs
61 lines (53 loc) · 1.53 KB
/
next.config.mjs
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
import createMdx from "@next/mdx";
import fs from "fs-extra";
import { $ } from "zurk";
import rehypeKatex from "rehype-katex";
import { rehypePrettyCode } from "rehype-pretty-code";
import remarkFrontmatter from "remark-frontmatter";
import remarkGfm from "remark-gfm";
import remarkMath from "remark-math";
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
import rehypeMdxExcerpt from "./src/rehype-mdx-excerpt.mjs";
import rehypeMermaid from "./src/rehype-mermaid.mjs";
import rehypePseudocode from "./src/rehype-pseudocode.mjs";
const isProduction = process.env.NODE_ENV === "production";
const basePath = isProduction ? "/blog" : "";
const withMdx = createMdx({
options: {
remarkPlugins: [
remarkGfm,
remarkFrontmatter,
remarkMath,
remarkMdxFrontmatter,
],
rehypePlugins: [
[rehypeKatex, { trust: true, strict: false }],
rehypePseudocode,
rehypeMermaid,
rehypePrettyCode,
rehypeMdxExcerpt,
],
remarkRehypeOptions: {
footnoteLabel: "脚注",
},
},
});
/** @type {import('next').NextConfig} */
const nextConfig = {
basePath,
trailingSlash: true,
output: "export",
reactStrictMode: true,
pageExtensions: ["js", "jsx", "mdx", "ts", "tsx"],
images: { unoptimized: true },
env: {
BLOG_BASE_PATH: basePath,
},
};
if (process.env.RUN_OG_IMAGE === "1") {
await $`bun scripts/og-image.jsx`;
}
if (process.env.RUN_PAGEFIND === "1" || !fs.pathExistsSync("public/pagefind")) {
await $`bun scripts/pagefind.js`;
}
export default withMdx(nextConfig);