forked from Semantic-Org/Semantic-UI-React
-
Notifications
You must be signed in to change notification settings - Fork 0
/
static.routes.js
134 lines (125 loc) · 3.74 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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(
_.filter(getComponentMenu(), (baseInfo) => !baseInfo.external),
(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]),
}
},
}),
),
{
path: `/addons/ref/`,
component: 'docs/src/components/ComponentDoc',
priority: 0.8,
getData: async () => {
const componentsInfo = {
Ref: {
displayName: 'Ref',
props: [
{
description: ['Called when a child component will be mounted or updated.'],
name: 'innerRef',
type: 'func',
required: true,
tags: [
{
title: 'param',
description: 'Referred node.',
type: {
type: 'NameExpression',
name: 'HTMLElement',
},
name: 'node',
},
],
},
],
type: 'addon',
isParent: true,
subcomponents: [],
docblock: {
tags: [],
description: [
'This component exposes the `innerRef` prop that supports functional and React.createRef()/React.useRef() API and returns the DOM node of both functional and class component children.',
],
},
examplesExist: true,
},
}
const sidebarSections = getSidebarSections('Ref')
return {
componentsInfo,
exampleSources,
sidebarSections,
displayName: 'Ref',
deprecated: true,
seeTags: [],
}
},
},
// 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,
}),
})),
]
}