This repository was archived by the owner on Dec 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.mjs
85 lines (82 loc) · 2.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import withMDX from "@next/mdx";
import rehypeSlug from "rehype-slug";
import rehypeToc from "@atomictech/rehype-toc"; // pending merge of https://github.com/JS-DevTools/rehype-toc/pull/3
import rehypeHeadings from "rehype-autolink-headings";
import rehypeUrl from "rehype-url-inspector";
import url from "url";
function trimUrl(url) {
// Utility function to remove (index).md from page URLs
url = url.replace(/\/index\.md$/, "");
url = url.replace(/\.md$/, "");
return url;
}
const mdx = withMDX({
extension: /\.(md)$/,
options: {
rehypePlugins: [
[rehypeSlug],
[
rehypeHeadings,
{
behavior: "append",
content: {
type: "element",
tagName: "span",
properties: { className: ["fas", "fa-link", "anchor-link"] },
children: [],
},
},
],
[
rehypeToc,
{
placeholder: "{{TOC}}",
nav: false,
headings: ["h1", "h2", "h3"],
},
],
[
rehypeUrl,
{
inspectEach(match) {
if (match.url) {
// Use lenient parser since we are dealing with partial URLs
const parsedUrl = url.parse(match.url);
if (parsedUrl.hostname) {
// Do nothing for external links
return;
}
if (parsedUrl.pathname) {
// Trim (index).md extension from links
parsedUrl.pathname = trimUrl(parsedUrl.pathname);
match.node.properties[match.propertyName] =
url.format(parsedUrl);
}
}
},
},
],
],
remarkPlugins: [],
},
});
export default mdx({
pageExtensions: ["md", "js", "jsx"],
publicRuntimeConfig: {
// Be sure to customize these values for your site. Changing these values
// requires restarting the dev server.
headerLinks: {
// A list of links for the header of every page, relative to root.
Home: "/",
Team: "/company/team/index.md",
},
editRepositoryBase:
// This is the base path for the "edit this page" link. The relative path
// of the current page from the root is added. No trailing slash. If unset,
// no edit page link will be shown.
"https://github.com/async-go/company-handbook-template/edit/main/pages",
historyRepositoryBase:
// Same as above, except to show the history of a page.
"https://github.com/async-go/company-handbook-template/commits/main/pages",
},
});