-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
next.config.js
36 lines (34 loc) · 998 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
const SUMMARY_JSON = require('./content/summary.json')
module.exports = {
exportPathMap: function() {
const posts = {}
const paths = {}
SUMMARY_JSON.fileMap && Object.keys(SUMMARY_JSON.fileMap)
.forEach((file) => {
const fileObj = SUMMARY_JSON.fileMap[file]
const obj = {}
if (fileObj.paths) {
// Handle custom paths / aliases.
obj.page = '/post'
obj.query = {
fullUrl: file.match(/^content(.+)\.json$/)[1]
}
fileObj.paths.forEach((path) => {
paths[path] = obj
})
} else if (file.indexOf('content/posts') === 0) {
// Handle posts.
const page = file.split('content').join('').split('.json').join('')
posts[page] = {
page: '/post',
query: {
fullUrl: page
}
}
}
})
return Object.assign({}, {
'/': { page: '/' }
}, posts, paths) // aliases
}
}