-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathnext.config.mjs
64 lines (56 loc) · 1.41 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
62
63
64
import remarkHeadingId from "remark-custom-heading-id";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
const { findAndReplace } = await import("mdast-util-find-and-replace");
const baseRepoUrl = "https://github.com/Chatterino/Chatterino2";
// -- #1234 issues
function githubIssueLinks(options) {
return (tree) => {
findAndReplace(tree, [[/#\d+/g, replace]], {
ignore: ["link", "linkReference"],
});
};
function replace(value, _no, _match) {
return {
type: "link",
title: null,
url: `${baseRepoUrl}/issues/${value.slice(1)}`,
children: [{ type: "text", value }],
};
}
}
function majorMinorColoring() {
return (tree) => {
findAndReplace(tree, [[/Major:/g, replace]], {
ignore: ["link", "linkReference"],
});
};
function replace(value, _no, _match) {
return {
type: "strong",
children: [{ type: "text", value }],
};
}
}
// -- config
const withMDX = (await import("@next/mdx")).default({
extension: /\.mdx$/,
options: {
remarkPlugins: [githubIssueLinks, majorMinorColoring, remarkHeadingId],
rehypePlugins: [
[
rehypeAutolinkHeadings,
{
behavior: "append",
content: {
type: "text",
value: "#",
},
},
],
],
},
});
export default withMDX({
pageExtensions: ["js", "jsx", "ts", "tsx", "md", "mdx"],
output: "export",
});