|
1 |
| -const shell = require('shelljs'); |
2 |
| -const path = require('path'); |
| 1 | +const path = require("path"); |
3 | 2 |
|
4 |
| -const rootDir = path.join(__dirname, '.'); |
5 |
| -const contentDir = path.join(rootDir, 'content'); |
6 |
| -const docsDir = path.join(contentDir, 'docs'); |
7 |
| -const componentsDocsDir = path.join(docsDir, 'components'); |
| 3 | +const shell = require("shelljs"); |
| 4 | + |
| 5 | +const rootDir = path.join(__dirname, "."); |
| 6 | +const contentDir = path.join(rootDir, "content"); |
| 7 | +const docsDir = path.join(contentDir, "docs"); |
| 8 | +const componentsDocsDir = path.join(docsDir, "components"); |
8 | 9 |
|
9 | 10 | const getComponentsName = () => {
|
10 | 11 | const names = shell
|
11 |
| - .ls('-R', componentsDocsDir) |
| 12 | + .ls("-R", componentsDocsDir) |
12 | 13 | .map((file) => path.join(process.cwd(), componentsDocsDir, file))
|
13 |
| - .filter((file) => file.endsWith('.mdx')) |
14 |
| - .map((file) => path.basename(file, '.mdx')); |
| 14 | + .filter((file) => file.endsWith(".mdx")) |
| 15 | + .map((file) => path.basename(file, ".mdx")); |
| 16 | + |
15 | 17 | return names;
|
16 | 18 | };
|
17 | 19 | const getComponentsRoute = (names = []) => {
|
18 | 20 | return names.map((name) => {
|
19 | 21 | return {
|
20 | 22 | source: `/${name}`,
|
21 | 23 | destination: `/docs/components/${name}`,
|
22 |
| - permanent: true |
| 24 | + permanent: true, |
23 | 25 | };
|
24 | 26 | });
|
25 | 27 | };
|
26 | 28 |
|
27 | 29 | async function redirect() {
|
28 | 30 | const componentsName = getComponentsName();
|
| 31 | + |
29 | 32 | return [
|
30 | 33 | ...getComponentsRoute(componentsName),
|
31 | 34 | {
|
32 |
| - source: '/docs', |
33 |
| - destination: '/docs/guide/getting-started', |
34 |
| - permanent: true |
| 35 | + source: "/docs", |
| 36 | + destination: "/docs/guide/getting-started", |
| 37 | + permanent: true, |
35 | 38 | },
|
36 | 39 | {
|
37 |
| - source: '/docs/getting-started', |
38 |
| - destination: '/docs/guide/getting-started', |
39 |
| - permanent: true |
| 40 | + source: "/docs/getting-started", |
| 41 | + destination: "/docs/guide/getting-started", |
| 42 | + permanent: true, |
40 | 43 | },
|
41 | 44 | {
|
42 |
| - source: '/guide', |
43 |
| - destination: '/docs/guide/getting-started', |
44 |
| - permanent: true |
| 45 | + source: "/guide", |
| 46 | + destination: "/docs/guide/getting-started", |
| 47 | + permanent: true, |
45 | 48 | },
|
46 | 49 | {
|
47 |
| - source: '/learn', |
48 |
| - destination: '/docs/guide/getting-started', |
49 |
| - permanent: true |
| 50 | + source: "/learn", |
| 51 | + destination: "/docs/guide/getting-started", |
| 52 | + permanent: true, |
50 | 53 | },
|
51 | 54 | {
|
52 |
| - source: '/theme', |
53 |
| - destination: '/docs/theme/default-theme', |
54 |
| - permanent: true |
| 55 | + source: "/theme", |
| 56 | + destination: "/docs/theme/default-theme", |
| 57 | + permanent: true, |
55 | 58 | },
|
56 | 59 | {
|
57 |
| - source: '/docs/theme', |
58 |
| - destination: '/docs/theme/default-theme', |
59 |
| - permanent: true |
| 60 | + source: "/docs/theme", |
| 61 | + destination: "/docs/theme/default-theme", |
| 62 | + permanent: true, |
60 | 63 | },
|
61 | 64 | {
|
62 |
| - source: '/components/:path*', |
| 65 | + source: "/components/:path*", |
63 | 66 | permanent: true,
|
64 |
| - destination: '/docs/components/:path*' |
| 67 | + destination: "/docs/components/:path*", |
65 | 68 | },
|
66 | 69 | {
|
67 |
| - source: '/docs/components', |
68 |
| - destination: '/docs/components/button', |
69 |
| - permanent: true |
| 70 | + source: "/docs/components", |
| 71 | + destination: "/docs/components/button", |
| 72 | + permanent: true, |
70 | 73 | },
|
71 | 74 | {
|
72 |
| - source: '/components', |
73 |
| - destination: '/docs/components/button', |
74 |
| - permanent: true |
75 |
| - } |
| 75 | + source: "/components", |
| 76 | + destination: "/docs/components/button", |
| 77 | + permanent: true, |
| 78 | + }, |
76 | 79 | ];
|
77 | 80 | }
|
78 | 81 |
|
|
0 commit comments