forked from masives/netlifycms-nextjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
37 lines (35 loc) · 819 Bytes
/
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
const fs = require('fs');
const blogPostsFolder = './content/blogPosts';
const getPathsForPosts = () => {
return fs
.readdirSync(blogPostsFolder)
.map(blogName => {
const trimmedName = blogName.substring(0, blogName.length - 3);
return {
[`/blog/post/${trimmedName}`]: {
page: '/blog/post/[slug]',
query: {
slug: trimmedName,
},
},
};
})
.reduce((acc, curr) => {
return { ...acc, ...curr };
}, {});
};
module.exports = {
webpack: configuration => {
configuration.module.rules.push({
test: /\.md$/,
use: 'frontmatter-markdown-loader',
});
return configuration;
},
async exportPathMap(defaultPathMap) {
return {
...defaultPathMap,
...getPathsForPosts(),
};
},
};