Skip to content

Commit 080c3ab

Browse files
[docs] Remove pages duplication and reduce out-of-sync
1 parent 053a29e commit 080c3ab

File tree

1 file changed

+57
-274
lines changed

1 file changed

+57
-274
lines changed

docs/src/pages.js

Lines changed: 57 additions & 274 deletions
Original file line numberDiff line numberDiff line change
@@ -1,277 +1,60 @@
1-
import findPages from /* preval */ 'docs/src/modules/utils/findPages';
1+
import pages from '@material-ui/monorepo/docs/src/pages';
22

3-
const pages = [
4-
{
5-
pathname: '/getting-started',
6-
children: [
7-
{ pathname: '/getting-started/installation' },
8-
{ pathname: '/getting-started/usage' },
9-
{ pathname: '/getting-started/example-projects' },
10-
{ pathname: '/getting-started/templates' },
11-
{ pathname: '/getting-started/learn' },
12-
{ pathname: '/getting-started/faq', title: 'FAQs' },
13-
{ pathname: '/getting-started/supported-components' },
14-
{ pathname: '/getting-started/supported-platforms' },
15-
{ pathname: '/getting-started/support' },
16-
],
17-
},
18-
{
19-
pathname: '/components',
20-
children: [
21-
{
22-
pathname: '/components',
23-
subheader: '/components/layout',
24-
children: [
25-
{ pathname: '/components/box' },
26-
{ pathname: '/components/container' },
27-
{ pathname: '/components/grid' },
28-
{ pathname: '/components/grid-list' },
29-
{ pathname: '/components/hidden' },
30-
],
31-
},
32-
{
33-
pathname: '/components',
34-
subheader: '/components/inputs',
35-
children: [
36-
{ pathname: '/components/buttons' },
37-
{ pathname: '/components/button-group' },
38-
{ pathname: '/components/checkboxes' },
39-
{ pathname: '/components/floating-action-button' },
40-
{ pathname: '/components/pickers', title: 'Date / Time' },
41-
{ pathname: '/components/radio-buttons' },
42-
{ pathname: '/components/selects' },
43-
{ pathname: '/components/slider' },
44-
{ pathname: '/components/switches' },
45-
{ pathname: '/components/text-fields' },
46-
{ pathname: '/components/transfer-list' },
47-
],
48-
},
49-
{
50-
pathname: '/components',
51-
subheader: '/components/navigation',
52-
children: [
53-
{ pathname: '/components/bottom-navigation' },
54-
{ pathname: '/components/breadcrumbs' },
55-
{ pathname: '/components/drawers' },
56-
{ pathname: '/components/links' },
57-
{ pathname: '/components/menus' },
58-
{ pathname: '/components/steppers' },
59-
{ pathname: '/components/tabs' },
60-
],
61-
},
62-
{
63-
pathname: '/components',
64-
subheader: '/components/surfaces',
65-
children: [
66-
{ pathname: '/components/app-bar' },
67-
{ pathname: '/components/paper' },
68-
{ pathname: '/components/cards' },
69-
{ pathname: '/components/accordion' },
70-
],
71-
},
72-
{
73-
pathname: '/components',
74-
subheader: '/components/feedback',
75-
children: [
76-
{ pathname: '/components/progress' },
77-
{ pathname: '/components/dialogs' },
78-
{ pathname: '/components/snackbars' },
79-
{ pathname: '/components/backdrop' },
80-
],
81-
},
82-
{
83-
pathname: '/components',
84-
subheader: '/components/data-display',
85-
children: [
86-
{ pathname: '/components/avatars' },
87-
{ pathname: '/components/badges' },
88-
{ pathname: '/components/chips' },
89-
{ pathname: '/components/dividers' },
90-
{ pathname: '/components/icons' },
91-
{ pathname: '/components/material-icons' },
92-
{ pathname: '/components/lists' },
93-
{ pathname: '/components/tables' },
94-
{ pathname: '/components/tooltips' },
95-
{ pathname: '/components/typography' },
96-
],
97-
},
98-
{
99-
pathname: '/components',
100-
subheader: '/components/utils',
101-
children: [
102-
{ pathname: '/components/click-away-listener' },
103-
{ pathname: '/components/css-baseline', title: 'CSS Baseline' },
104-
{ pathname: '/components/modal' },
105-
{ pathname: '/components/no-ssr', title: 'No SSR' },
106-
{ pathname: '/components/popover' },
107-
{ pathname: '/components/popper' },
108-
{ pathname: '/components/portal' },
109-
{ pathname: '/components/textarea-autosize' },
110-
{ pathname: '/components/transitions' },
111-
{ pathname: '/components/use-media-query', title: 'useMediaQuery' },
112-
],
113-
},
114-
{
115-
pathname: '/components',
116-
subheader: '/components/lab',
117-
children: [
118-
{ pathname: '/components/about-the-lab' },
119-
{ pathname: '/components/alert' },
120-
{ pathname: '/components/autocomplete' },
121-
{
122-
pathname: '/components',
123-
subheader: '/components/data-grid',
124-
children:
125-
process.env.PULL_REQUEST === 'false'
126-
? [
127-
{
128-
pathname: '/components/data-grid',
129-
title: 'Overview',
130-
},
131-
{ pathname: '/components/data-grid/getting-started' },
132-
{ pathname: '/components/data-grid/columns' },
133-
{ pathname: '/components/data-grid/rows' },
134-
{ pathname: '/components/data-grid/filtering', title: 'Filtering' },
135-
{ pathname: '/components/data-grid/pagination' },
136-
{ pathname: '/components/data-grid/selection' },
137-
{ pathname: '/components/data-grid/editing', title: '🚧 Editing' },
138-
{ pathname: '/components/data-grid/rendering' },
139-
{ pathname: '/components/data-grid/export', title: '🚧 Export & Import' },
140-
{ pathname: '/components/data-grid/localization', title: 'Localization' },
141-
{ pathname: '/components/data-grid/group-pivot', title: '🚧 Group & Pivot' },
142-
{ pathname: '/components/data-grid/accessibility' },
143-
]
144-
: [
145-
{
146-
pathname: '/components/data-grid',
147-
title: 'Overview',
148-
},
149-
{ pathname: '/components/data-grid/getting-started' },
150-
{ pathname: '/components/data-grid/columns' },
151-
{ pathname: '/components/data-grid/rows' },
152-
{ pathname: '/components/data-grid/filtering', title: 'Filtering' },
153-
{ pathname: '/components/data-grid/pagination' },
154-
{ pathname: '/components/data-grid/selection' },
155-
{ pathname: '/components/data-grid/editing', title: '🚧 Editing' },
156-
{ pathname: '/components/data-grid/rendering' },
157-
{ pathname: '/components/data-grid/export', title: '🚧 Export & Import' },
158-
{ pathname: '/components/data-grid/localization', title: 'Localization' },
159-
{ pathname: '/components/data-grid/group-pivot', title: '🚧 Group & Pivot' },
160-
{ pathname: '/components/data-grid/accessibility' },
161-
],
162-
},
163-
{ pathname: '/components/pagination' },
164-
{ pathname: '/components/rating' },
165-
{ pathname: '/components/skeleton' },
166-
{ pathname: '/components/speed-dial' },
167-
{ pathname: '/components/timeline' },
168-
{ pathname: '/components/toggle-button' },
169-
{ pathname: '/components/tree-view' },
170-
],
171-
},
172-
],
173-
},
174-
{
175-
title: 'Component API',
176-
pathname: '/api-docs',
177-
children: [
178-
...findPages[0].children,
179-
{ pathname: '/api-docs/data-grid' },
180-
{ pathname: '/api-docs/x-grid' },
181-
],
182-
},
183-
{
184-
pathname: '/styles',
185-
children: [
186-
{ pathname: '/styles/basics' },
187-
{ pathname: '/styles/advanced' },
188-
{ pathname: '/styles/api', title: 'API' },
189-
],
190-
},
191-
{
192-
pathname: '/system',
193-
children: [
194-
{ pathname: '/system/basics' },
195-
{ pathname: '/system/borders' },
196-
{ pathname: '/system/display' },
197-
{ pathname: '/system/flexbox' },
198-
{ pathname: '/system/palette' },
199-
{ pathname: '/system/positions' },
200-
{ pathname: '/system/shadows' },
201-
{ pathname: '/system/sizing' },
202-
{ pathname: '/system/spacing' },
203-
{ pathname: '/system/screen-readers' },
204-
{ pathname: '/system/typography' },
205-
{ pathname: '/system/api', title: 'API' },
206-
],
207-
},
208-
{
209-
pathname: '/customization',
210-
children: [
211-
{
212-
pathname: '/customization',
213-
subheader: '/customization/theme',
214-
children: [
215-
{ pathname: '/customization/theming' },
216-
{ pathname: '/customization/palette' },
217-
{ pathname: '/customization/typography' },
218-
{ pathname: '/customization/spacing' },
219-
{ pathname: '/customization/breakpoints' },
220-
{ pathname: '/customization/density' },
221-
{ pathname: '/customization/z-index', title: 'z-index' },
222-
{ pathname: '/customization/globals' },
223-
{ pathname: '/customization/transitions' },
224-
],
225-
},
226-
{ pathname: '/customization/components' },
227-
{ pathname: '/customization/color' },
228-
{ pathname: '/customization/default-theme', title: 'Default Theme' },
229-
],
230-
},
231-
{
232-
pathname: '/guides',
233-
children: [
234-
{ pathname: '/guides/api', title: 'API Design Approach' },
235-
{ pathname: '/guides/typescript', title: 'TypeScript' },
236-
{ pathname: '/guides/interoperability', title: 'Style Library Interoperability' },
237-
{ pathname: '/guides/minimizing-bundle-size' },
238-
{ pathname: '/guides/composition' },
239-
{ pathname: '/guides/server-rendering' },
240-
{ pathname: '/guides/responsive-ui', title: 'Responsive UI' },
241-
{ pathname: '/guides/migration-v4', title: 'Migration From v4' },
242-
{ pathname: '/guides/migration-v3', title: 'Migration From v3' },
243-
{ pathname: '/guides/migration-v0x', title: 'Migration From v0.x' },
244-
{ pathname: '/guides/testing' },
245-
{ pathname: '/guides/localization' },
246-
{ pathname: '/guides/right-to-left', title: 'Right-to-left' },
247-
{ pathname: '/guides/flow' },
248-
],
249-
},
250-
{
251-
pathname: 'https://material-ui.com/store/',
252-
title: 'Premium themes',
253-
linkProps: {
254-
'data-ga-event-category': 'store',
255-
'data-ga-event-action': 'click',
256-
'data-ga-event-label': 'sidenav',
257-
},
258-
},
259-
{
260-
pathname: '/discover-more',
261-
children: [
262-
{ pathname: '/discover-more/showcase' },
263-
{ pathname: '/discover-more/related-projects' },
264-
{ pathname: '/discover-more/roadmap' },
265-
{ pathname: '/discover-more/backers', title: 'Sponsors & Backers' },
266-
{ pathname: '/discover-more/vision' },
267-
{ pathname: '/discover-more/team' },
268-
{ pathname: '/discover-more/changelog' },
269-
{ pathname: '/discover-more/languages' },
270-
],
271-
},
272-
{ pathname: '/versions', disableNav: true },
273-
{ pathname: '/', displayNav: false, disableDrawer: true },
274-
{ pathname: 'https://medium.com/material-ui', title: 'Blog' },
275-
];
3+
const components = pages[1];
4+
5+
if (components.pathname !== '/components') {
6+
throw new Error('Integration not compatible.');
7+
}
8+
9+
const lab = components.children[components.children.length - 1];
10+
11+
if (lab.subheader !== '/components/lab') {
12+
throw new Error('Integration not compatible.');
13+
}
14+
15+
const datagrid = lab.children[3];
16+
17+
if (datagrid.subheader !== '/components/data-grid') {
18+
throw new Error('Integration not compatible.');
19+
}
20+
21+
datagrid.children =
22+
process.env.PULL_REQUEST === 'false'
23+
? [
24+
{
25+
pathname: '/components/data-grid',
26+
title: 'Overview',
27+
},
28+
{ pathname: '/components/data-grid/getting-started' },
29+
{ pathname: '/components/data-grid/columns' },
30+
{ pathname: '/components/data-grid/rows' },
31+
{ pathname: '/components/data-grid/filtering', title: 'Filtering' },
32+
{ pathname: '/components/data-grid/pagination' },
33+
{ pathname: '/components/data-grid/selection' },
34+
{ pathname: '/components/data-grid/editing', title: '🚧 Editing' },
35+
{ pathname: '/components/data-grid/rendering' },
36+
{ pathname: '/components/data-grid/export', title: '🚧 Export & Import' },
37+
{ pathname: '/components/data-grid/localization', title: 'Localization' },
38+
{ pathname: '/components/data-grid/group-pivot', title: '🚧 Group & Pivot' },
39+
{ pathname: '/components/data-grid/accessibility' },
40+
]
41+
: [
42+
{
43+
pathname: '/components/data-grid',
44+
title: 'Overview',
45+
},
46+
{ pathname: '/components/data-grid/getting-started' },
47+
{ pathname: '/components/data-grid/columns' },
48+
{ pathname: '/components/data-grid/rows' },
49+
{ pathname: '/components/data-grid/filtering', title: 'Filtering' },
50+
{ pathname: '/components/data-grid/pagination' },
51+
{ pathname: '/components/data-grid/selection' },
52+
{ pathname: '/components/data-grid/editing', title: '🚧 Editing' },
53+
{ pathname: '/components/data-grid/rendering' },
54+
{ pathname: '/components/data-grid/export', title: '🚧 Export & Import' },
55+
{ pathname: '/components/data-grid/localization', title: 'Localization' },
56+
{ pathname: '/components/data-grid/group-pivot', title: '🚧 Group & Pivot' },
57+
{ pathname: '/components/data-grid/accessibility' },
58+
];
27659

27760
export default pages;

0 commit comments

Comments
 (0)