-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnext.config.js
56 lines (53 loc) · 1.43 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const path = require('path')
const pageMap = require('./page-map')
const emitLoader = {
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]',
},
}
module.exports = {
webpack(config) {
// Add a custom loaders for markdown files (and the images they reference)
config.module = config.module || {}
config.module.rules = config.module.rules || []
config.module.rules.push({test: /\.png$/, use: [emitLoader, 'url-loader?mimetype=image/png']})
config.module.rules.push({
test: /\.md(\?[^?]*)?$/,
use: [
emitLoader,
{
loader: 'html-loader',
options: {
root: 'https://github.com/attic-labs/noms',
attrs: ['img:src'],
},
},
{
loader: 'showdown-loader',
},
{
loader: 'link-map-loader',
},
],
})
config.resolveLoader = config.resolveLoader || {}
config.resolveLoader.modules = config.resolveLoader.modules || []
config.resolveLoader.modules.push(path.join(__dirname, './loaders'))
return config
},
async exportPathMap() {
const pages = pageMap(
p => ({
page: '/doc',
query: p,
}),
p => `/${p.src}`,
)
// Combine the map of post pages with the decent landing page
return Object.assign({}, pages, {
'/docs': {page: '/doc', query: {src: 'README.md'}},
'/decent': {page: '/decent'},
})
},
}