-
Notifications
You must be signed in to change notification settings - Fork 129
/
next.config.js
50 lines (43 loc) · 1.15 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
const withImages = require('next-images')
const slug = require('rehype-slug')
const generateGuidebook = require('generate-guidebook/next')
const pkg = require('./package.json')
const { locales, defaultLocale } = pkg.guidebook.i18n
const withGuidebooks = nextConfig =>
locales.reduce(
(nextConfig, locale) =>
generateGuidebook({
guidebookDirectory:
locale === defaultLocale ? './pages' : `./pages/${locale}`,
guidebookModulePath: `./guidebook-${locale}.js`,
})(nextConfig),
nextConfig
)
const withMDX = require('next-mdx-frontmatter')({
extension: /\.mdx?$/,
MDXOptions: {
rehypePlugins: [slug],
},
})
const withRawExampleLoader = nextConfig => ({
...nextConfig,
webpack(config, options) {
config.module.rules.push({
test: /examples(\/|\\)files(\/|\\).*$/,
use: 'raw-loader',
})
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
},
})
module.exports = withRawExampleLoader(
withGuidebooks(
withImages(
withMDX({
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
})
)
)
)