-
Notifications
You must be signed in to change notification settings - Fork 40
/
next.config.js
82 lines (76 loc) · 2.01 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { getHighlighter, BUNDLED_LANGUAGES } from 'shiki';
import nextra from 'nextra';
import fs from 'fs';
const grammar_tact = JSON.parse(fs.readFileSync('./grammars/grammar-tact.json', 'utf-8'));
const grammar_func = JSON.parse(fs.readFileSync('./grammars/grammar-func.json', 'utf-8'));
const grammar_ohm = JSON.parse(fs.readFileSync('./grammars/grammar-ohm.json', 'utf-8'));
const rehypePrettyCodeOptions = {
getHighlighter: options => {
return getHighlighter({
...options,
// NOTE: current version of Nextra doesn't support having dual themes,
// but this version of One Dark looks good enough in the light mode too.
theme: 'one-dark-pro',
langs: [
...BUNDLED_LANGUAGES,
{
id: 'tact',
scopeName: 'source.tact',
grammar: grammar_tact,
aliases: ['tact'],
},
{
id: 'func',
scopeName: 'source.func',
grammar: grammar_func,
aliases: ['func'],
},
{
id: 'ohm',
scopeName: 'source.ohm',
grammar: grammar_ohm,
aliases: ['ohm'],
},
],
});
},
};
/**
* @type {import('next').NextConfig}
*/
const withNextra = nextra({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.jsx',
mdxOptions: {
rehypePrettyCodeOptions
},
latex: true,
defaultShowCopyCode: true
});
/**
* @type {import('next').NextConfig}
*/
export default withNextra({
output: 'export',
images: {
unoptimized: true
},
// i18n: {
// // locales: ['default', 'en', 'zh'],
// locales: ['default', 'en'],
// defaultLocale: 'default',
// // localeDetection: false,
// },
webpack(config) {
const allowedSvgRegex = /components\/icons\/.+\.svg$/
const fileLoaderRule = config.module.rules.find(rule =>
rule.test?.test?.('.svg')
)
fileLoaderRule.exclude = allowedSvgRegex
config.module.rules.push({
test: allowedSvgRegex,
use: ['@svgr/webpack']
})
return config
},
});