-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
52 lines (48 loc) · 1.44 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
const withPlugins = require('next-compose-plugins')
const withMdxEnhanced = require('next-mdx-enhanced')
const checkEnv = require('@47ng/check-env').default
const nodePath = require('path')
const readingTime = require('reading-time')
checkEnv({
required: ['NEXT_PUBLIC_DEPLOYMENT_URL'],
})
const isProd = process.env.NODE_ENV === 'production'
const useURL = (path) =>
`${process.env.NEXT_PUBLIC_DEPLOYMENT_URL}${path || ''}`
const nextConfig = {
assetPrefix: '',
}
module.exports = withPlugins(
[
withMdxEnhanced({
layoutPath: 'src/layouts',
defaultLayout: true,
fileExtensions: ['mdx'],
remarkPlugins: [
require('remark-slug'),
require('remark-footnotes'),
require('remark-code-titles'),
//require('@fec/remark-a11y-emoji')
],
rehypePlugins: [require('mdx-prism')],
extendFrontMatter: {
process: (mdxContent, frontMatter) => {
const pagesDir = nodePath.resolve(__dirname, 'src/pages')
// Somehow the __resourcePath does not start with a /:
const path = ('/' + frontMatter.__resourcePath)
.replace(pagesDir, '')
.replace('.mdx', '')
.replace('.tsx', '')
.replace(/^\/index$/, '/')
.replace(/\/index$/, '')
return {
path,
url: useURL(path),
readingTime: readingTime(mdxContent),
}
},
},
}),
],
nextConfig,
)