1 |
import createMDX from "@next/mdx"; |
2 |
import rehypeAutolinkHeadings from "rehype-autolink-headings"; |
3 |
import rehypePrettyCode from "rehype-pretty-code"; |
4 |
import rehypeSlug from "rehype-slug"; |
5 |
import remarkFrontmatter from "remark-frontmatter"; |
6 |
import remarkGfm from "remark-gfm"; |
7 |
import remarkMdxFrontmatter from "remark-mdx-frontmatter"; |
8 |
|
9 |
/** @type {import('next').NextConfig} */ |
10 |
const nextConfig = { |
11 |
pageExtensions: ["js", "jsx", "mdx", "ts", "tsx", "md"], |
12 |
async rewrites() { |
13 |
return [{ source: "/:path*.(mdx?)", destination: "/:path*" }]; |
14 |
}, |
15 |
}; |
16 |
|
17 |
/** @type {import('rehype-pretty-code').Options} */ |
18 |
const rehypePrettyCodeOptions = { |
19 |
theme: "material-theme-ocean", |
20 |
}; |
21 |
|
22 |
const withMDX = createMDX({ |
23 |
extension: /\.mdx?$/, |
24 |
options: { |
25 |
remarkPlugins: [ |
26 |
remarkGfm, |
27 |
remarkFrontmatter, |
28 |
[remarkMdxFrontmatter, { name: "metadata" }], |
29 |
], |
30 |
rehypePlugins: [ |
31 |
rehypeSlug, |
32 |
[ |
33 |
rehypeAutolinkHeadings, |
34 |
{ |
35 |
behavior: "append", |
36 |
properties: { className: "autolink", tabindex: -1 }, |
37 |
}, |
38 |
], |
39 |
[rehypePrettyCode, rehypePrettyCodeOptions], |
40 |
], |
41 |
}, |
42 |
webpack(config) { |
43 |
require("./generate-sitemap.js"); |
44 |
return config; |
45 |
}, |
46 |
}); |
47 |
|
48 |
export default withMDX(nextConfig); |