-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathnext.config.js
41 lines (35 loc) · 1 KB
/
next.config.js
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
const glob = require("glob");
const path = require("path");
module.exports = {
webpack: (config) => {
config.module.rules.push({
test: /\.md$/,
use: "raw-loader",
});
return config;
},
exportPathMap: async function () {
// scan tutorials
const tutorials = glob.sync(
path.join(__dirname, "tutorials", "**", "*.md")
);
tutorialPages = {};
tutorials.forEach((file) => {
const name = path.parse(file).name;
tutorialPages[`/tutorials/${name}`] = {
page: `/tutorials/[name]`,
query: { name },
};
});
const pages = glob.sync(path.join(__dirname, "pages", "**", "*.tsx"));
staticPages = {};
pages.forEach((file) => {
if (file.match("pages/index.tsx")) return;
if (file.indexOf("]") >= 0) return;
const name = path.parse(file).name;
staticPages[`/${name}`] = { page: `/${name}` };
});
routes = Object.assign({ "/": { page: "/" } }, tutorialPages, staticPages);
return routes;
},
};