-
Notifications
You must be signed in to change notification settings - Fork 35
/
next.config.mjs
58 lines (52 loc) · 1.5 KB
/
next.config.mjs
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
57
58
import path from 'path'
import withMarkdoc from '@markdoc/next.js'
import withSearch from './src/markdoc/search.mjs'
import withNavigation from './src/markdoc/navigation.mjs'
import { createLoader } from 'simple-functional-loader'
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
pageExtensions: ['js', 'jsx', 'md'],
output: 'export',
distDir: 'dist',
env: {
SITE_URL: 'https://storj.dev',
NEXT_PUBLIC_SITE_URL: 'https://storj.dev',
},
experimental: {
scrollRestoration: true,
},
images: {
unoptimized: true,
},
webpack(config) {
config.module.rules.unshift({
test: /\.md$/,
use: [
createLoader(function (source) {
const relativePath = path.relative(process.cwd(), this.resourcePath)
let cleanedPath = relativePath
.replace('app', '')
.replace('/page.md', '')
.replace('/(docs)', '')
.replace('/(blog)', '')
if (cleanedPath === '') {
cleanedPath = '/'
}
return (
source +
'\nexport const metadata = frontmatter.metadata || frontmatter.nextjs?.metadata || {};' +
'\nmetadata.title = metadata.title || frontmatter.title;' +
`\nmetadata.alternates = { canonical: "${cleanedPath}" };`
)
}),
],
})
return config
},
}
export default withNavigation(
withSearch(
withMarkdoc({ schemaPath: './src/markdoc', nextjsExports: [] })(nextConfig)
)
)