-
Notifications
You must be signed in to change notification settings - Fork 49
/
next.config.mjs
65 lines (58 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
59
60
61
62
63
64
65
import nextra from 'nextra'
import { visit } from 'unist-util-visit'
import { hasProperty } from 'hast-util-has-property'
const getAndRemoveConfig = (str = '') => {
const config = {};
if (str) {
str = str
.replace(/^('|")/, '')
.replace(/('|")$/, '')
.replace(/(?:^|\s):([\w-]+:?)=?([\w-%]+)?/g, (m, key, value) => {
if (key.indexOf(':') === -1) {
config[key] = (value && value.replace(/"/g, '')) || true;
return '';
}
return m;
})
.trim();
}
return { str, config };
}
export const rehypeImageSize = () => (tree) => {
visit(tree, 'element', (node) => {
if (node.tagName === 'img' && hasProperty(node, 'title')) {
const { config } = getAndRemoveConfig(node.properties.title);
if (config.size) {
delete node.properties.title;
node.properties.width = config.size;
}
}
});
};
const withNextra = nextra({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.tsx',
mdxOptions: {
remarkPlugins: [],
rehypePlugins: [rehypeImageSize],
}
})
export default withNextra({
basePath: '/docs',
async redirects() {
return [
{
source: '/assessments/growth',
destination: 'https://app.sunnylife42.com/assessments/growth',
permanent: true,
basePath: false
},
{
source: '/documents/new',
destination: 'https://app.sunnylife42.com//documents/new',
permanent: true,
basePath: false
}
]
},
})