-
Notifications
You must be signed in to change notification settings - Fork 0
/
static.config.js
36 lines (32 loc) · 1008 Bytes
/
static.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
import path from 'path';
import jdown from 'jdown';
import {rebuildRoutes} from 'react-static/node'
const docsDir = 'src/docs';
const docRoutes = docsContent => Object.keys(docsContent).map(parentKey => {
return Object.keys(docsContent[parentKey]).map(childKey => {
const parent = docsContent[parentKey];
const child = docsContent[parentKey][childKey];
return {
path: `${parentKey}/${child.slug}`,
template: 'src/templates/Docs',
getData: () => ({docsContent, doc: child})
}
})
}).reduce((acc, next) => ([...acc, ...next]), []);
export default {
plugins: [
'react-static-plugin-react-router',
[require.resolve('react-static-plugin-source-filesystem'), {
location: 'src/pages'
}]
],
getRoutes: async () => {
const docsContent = await jdown(docsDir);
return [{
path: '/docs',
template: 'src/templates/Docs',
getData: () => ({}),
children: docRoutes(docsContent)
}];
}
}