forked from Semantic-Org/Semantic-UI-React
-
Notifications
You must be signed in to change notification settings - Fork 0
/
static.routes.js
79 lines (72 loc) · 2.14 KB
/
static.routes.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
import _ from 'lodash'
import {
getComponentGroupInfo,
getComponentMenu,
getExampleSources,
getInfoForSeeTags,
getLayoutPaths,
getPagesPaths,
getSidebarSections,
} from './docs/static/utils'
import { getComponentPathname } from './docs/src/utils'
export default async () => {
const exampleSources = getExampleSources()
return [
{
path: '/',
component: 'docs/src/pages/Introduction',
priority: 1,
},
{
component: 'docs/src/pages/PageNotFound',
is404: true,
},
// Routes for pages, i.e /theming
..._.map(getPagesPaths(), ({ pageName, routeName }) => ({
path: routeName,
component: 'docs/src/components/DocumentationPage',
priority: 0.9,
getData: async () => ({
pageName,
}),
})),
// Routes for components, i.e. /element/button
..._.map(getComponentMenu(), (baseInfo) => ({
path: getComponentPathname(baseInfo),
component: 'docs/src/components/ComponentDoc',
priority: 0.8,
getData: async () => {
const componentsInfo = getComponentGroupInfo(baseInfo.displayName)
const sidebarSections = getSidebarSections(baseInfo.displayName)
return {
componentsInfo,
exampleSources,
sidebarSections,
displayName: baseInfo.displayName,
deprecated: !!_.find(
_.get(componentsInfo[baseInfo.displayName], 'docblock.tags'),
(tag) => tag.title === 'deprecated',
),
seeTags: getInfoForSeeTags(componentsInfo[baseInfo.displayName]),
}
},
})),
// Routes for layouts, i.e. /layouts/theming
..._.map(await getLayoutPaths(), ({ routeName, componentFilename }) => ({
path: `/layouts/${routeName}`,
component: 'docs/src/components/LayoutsLayout',
priority: 0.7,
getData: async () => ({
componentFilename,
}),
})),
..._.map(exampleSources, (source, path) => ({
path: `/maximize/${_.kebabCase(path.split('/').slice(-1))}`,
component: 'docs/src/components/ExternalExampleLayout',
priority: 0.4,
getData: async () => ({
path,
}),
})),
]
}