1 |
import rehypePrism from "@mapbox/rehype-prism"; |
2 |
import createMDX from "@next/mdx"; |
3 |
import rehypeAutolinkHeadings from "rehype-autolink-headings"; |
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 |
const withMDX = createMDX({ |
18 |
extension: /\.mdx?$/, |
19 |
options: { |
20 |
remarkPlugins: [ |
21 |
remarkGfm, |
22 |
remarkFrontmatter, |
23 |
[remarkMdxFrontmatter, { name: "metadata" }], |
24 |
], |
25 |
rehypePlugins: [ |
26 |
rehypeSlug, |
27 |
[ |
28 |
rehypeAutolinkHeadings, |
29 |
{ |
30 |
behavior: "append", |
31 |
properties: { className: "autolink", tabindex: -1 }, |
32 |
}, |
33 |
], |
34 |
rehypePrism, |
35 |
], |
36 |
}, |
37 |
webpack(config) { |
38 |
require("./generate-sitemap.js"); |
39 |
return config; |
40 |
}, |
41 |
}); |
42 |
|
43 |
export default withMDX(nextConfig); |