From 90ea2e2f71bf76a069af8a3a51111b74a4043503 Mon Sep 17 00:00:00 2001 From: Charles Zhao Date: Tue, 5 Sep 2023 23:36:30 +0800 Subject: [PATCH] refactor(console): adjust sdk guide sorting order (#4427) * refactor(console): adjust sdk guide sorting order * docs(console): update rules about the sorting order of the sdk guides --- .../console/src/assets/docs/guides/README.md | 6 +- .../assets/docs/guides/generate-metadata.js | 8 +- .../console/src/assets/docs/guides/index.ts | 162 +++++++++--------- .../docs/guides/m2m-general/config.json | 3 + .../guides/native-android-java/config.json | 2 +- .../docs/guides/native-android-kt/config.json | 2 +- .../docs/guides/native-flutter/config.json | 2 +- .../docs/guides/native-ios-swift/config.json | 2 +- .../assets/docs/guides/spa-react/config.json | 2 +- .../docs/guides/spa-vanilla/config.json | 2 +- .../assets/docs/guides/spa-vue/config.json | 2 +- .../docs/guides/web-asp-net-core/config.json | 2 +- .../docs/guides/web-express/config.json | 2 +- .../src/assets/docs/guides/web-go/config.json | 2 +- .../docs/guides/web-gpt-plugin/config.json | 2 +- .../assets/docs/guides/web-java/config.json | 3 + .../docs/guides/web-outline/config.json | 2 +- .../assets/docs/guides/web-php/config.json | 2 +- .../assets/docs/guides/web-python/config.json | 2 +- .../assets/docs/guides/web-remix/config.json | 2 +- 20 files changed, 107 insertions(+), 105 deletions(-) create mode 100644 packages/console/src/assets/docs/guides/m2m-general/config.json create mode 100644 packages/console/src/assets/docs/guides/web-java/config.json diff --git a/packages/console/src/assets/docs/guides/README.md b/packages/console/src/assets/docs/guides/README.md index 0f0803d72..29f0f0dea 100644 --- a/packages/console/src/assets/docs/guides/README.md +++ b/packages/console/src/assets/docs/guides/README.md @@ -60,8 +60,10 @@ This may be fixed by replacing Parcel with something else. The guides are ordered by the following rules in ascending order: -1. The first segment of the directory name, which should be the target of the guide; -2. The `order` property of the guide. +1. The `order` property of all guides across all category groups +2. The sorting order should exactly follow the order in UX design. E.g. Next.js being the 1st one, React being the 2nd +3. The guides in featured group ("Popular and for you") should have `1.x` order value +4. The guides that are not listed in featured group can have order value equal to or greater than 2 You can configure the property by creating a `config.json` file in the guide directory. The file should be an object with the following structure: diff --git a/packages/console/src/assets/docs/guides/generate-metadata.js b/packages/console/src/assets/docs/guides/generate-metadata.js index 533653b5c..76eb4a05d 100644 --- a/packages/console/src/assets/docs/guides/generate-metadata.js +++ b/packages/console/src/assets/docs/guides/generate-metadata.js @@ -34,13 +34,7 @@ const data = await Promise.all( }; }) ); -const metadata = data.filter(Boolean).slice().sort((a, b) => { - if (a.name.split('-')[0] !== b.name.split('-')[0]) { - return a.name.localeCompare(b.name); - } - - return a.order - b.order; -}); +const metadata = data.filter(Boolean).slice().sort((a, b) => a.order - b.order); const camelCase = (value) => value.replaceAll(/-./g, (x) => x[1].toUpperCase()); const filename = 'index.ts'; diff --git a/packages/console/src/assets/docs/guides/index.ts b/packages/console/src/assets/docs/guides/index.ts index 04f92e922..ef9322446 100644 --- a/packages/console/src/assets/docs/guides/index.ts +++ b/packages/console/src/assets/docs/guides/index.ts @@ -24,69 +24,6 @@ import webPython from './web-python/index'; import webRemix from './web-remix/index'; const guides: Readonly = Object.freeze([ - { - order: Number.POSITIVE_INFINITY, - id: 'm2m-general', - Logo: lazy(async () => import('./m2m-general/logo.svg')), - Component: lazy(async () => import('./m2m-general/README.mdx')), - metadata: m2mGeneral, - }, - { - order: 1, - id: 'native-ios-swift', - Logo: lazy(async () => import('./native-ios-swift/logo.svg')), - Component: lazy(async () => import('./native-ios-swift/README.mdx')), - metadata: nativeIosSwift, - }, - { - order: 2, - id: 'native-android-java', - Logo: lazy(async () => import('./native-android-java/logo.svg')), - Component: lazy(async () => import('./native-android-java/README.mdx')), - metadata: nativeAndroidJava, - }, - { - order: 2.1, - id: 'native-android-kt', - Logo: lazy(async () => import('./native-android-kt/logo.svg')), - Component: lazy(async () => import('./native-android-kt/README.mdx')), - metadata: nativeAndroidKt, - }, - { - order: 3, - id: 'native-flutter', - Logo: lazy(async () => import('./native-flutter/logo.svg')), - Component: lazy(async () => import('./native-flutter/README.mdx')), - metadata: nativeFlutter, - }, - { - order: 4, - id: 'native-capacitor', - Logo: lazy(async () => import('./native-capacitor/logo.svg')), - Component: lazy(async () => import('./native-capacitor/README.mdx')), - metadata: nativeCapacitor, - }, - { - order: 1, - id: 'spa-react', - Logo: lazy(async () => import('./spa-react/logo.svg')), - Component: lazy(async () => import('./spa-react/README.mdx')), - metadata: spaReact, - }, - { - order: 2, - id: 'spa-vue', - Logo: lazy(async () => import('./spa-vue/logo.svg')), - Component: lazy(async () => import('./spa-vue/README.mdx')), - metadata: spaVue, - }, - { - order: 3, - id: 'spa-vanilla', - Logo: lazy(async () => import('./spa-vanilla/logo.svg')), - Component: lazy(async () => import('./spa-vanilla/README.mdx')), - metadata: spaVanilla, - }, { order: 1, id: 'web-next', @@ -94,6 +31,13 @@ const guides: Readonly = Object.freeze([ Component: lazy(async () => import('./web-next/README.mdx')), metadata: webNext, }, + { + order: 1.1, + id: 'spa-react', + Logo: lazy(async () => import('./spa-react/logo.svg')), + Component: lazy(async () => import('./spa-react/README.mdx')), + metadata: spaReact, + }, { order: 1.1, id: 'web-next-app-router', @@ -102,61 +46,117 @@ const guides: Readonly = Object.freeze([ metadata: webNextAppRouter, }, { - order: 2, + order: 1.2, + id: 'm2m-general', + Logo: lazy(async () => import('./m2m-general/logo.svg')), + Component: lazy(async () => import('./m2m-general/README.mdx')), + metadata: m2mGeneral, + }, + { + order: 1.2, id: 'web-express', Logo: lazy(async () => import('./web-express/logo.svg')), Component: lazy(async () => import('./web-express/README.mdx')), metadata: webExpress, }, { - order: 3, + order: 1.3, id: 'web-go', Logo: lazy(async () => import('./web-go/logo.svg')), Component: lazy(async () => import('./web-go/README.mdx')), metadata: webGo, }, { - order: 4, - id: 'web-python', - Logo: lazy(async () => import('./web-python/logo.svg')), - Component: lazy(async () => import('./web-python/README.mdx')), - metadata: webPython, + order: 1.5, + id: 'web-gpt-plugin', + Logo: lazy(async () => import('./web-gpt-plugin/logo.svg')), + Component: lazy(async () => import('./web-gpt-plugin/README.mdx')), + metadata: webGptPlugin, }, { - order: 5, + order: 1.6, + id: 'spa-vue', + Logo: lazy(async () => import('./spa-vue/logo.svg')), + Component: lazy(async () => import('./spa-vue/README.mdx')), + metadata: spaVue, + }, + { + order: 1.7, + id: 'native-ios-swift', + Logo: lazy(async () => import('./native-ios-swift/logo.svg')), + Component: lazy(async () => import('./native-ios-swift/README.mdx')), + metadata: nativeIosSwift, + }, + { + order: 2, + id: 'native-android-kt', + Logo: lazy(async () => import('./native-android-kt/logo.svg')), + Component: lazy(async () => import('./native-android-kt/README.mdx')), + metadata: nativeAndroidKt, + }, + { + order: 2, + id: 'spa-vanilla', + Logo: lazy(async () => import('./spa-vanilla/logo.svg')), + Component: lazy(async () => import('./spa-vanilla/README.mdx')), + metadata: spaVanilla, + }, + { + order: 2, id: 'web-php', Logo: lazy(async () => import('./web-php/logo.svg')), Component: lazy(async () => import('./web-php/README.mdx')), metadata: webPhp, }, { - order: 6, + order: 3, + id: 'native-android-java', + Logo: lazy(async () => import('./native-android-java/logo.svg')), + Component: lazy(async () => import('./native-android-java/README.mdx')), + metadata: nativeAndroidJava, + }, + { + order: 3, + id: 'web-python', + Logo: lazy(async () => import('./web-python/logo.svg')), + Component: lazy(async () => import('./web-python/README.mdx')), + metadata: webPython, + }, + { + order: 4, + id: 'native-capacitor', + Logo: lazy(async () => import('./native-capacitor/logo.svg')), + Component: lazy(async () => import('./native-capacitor/README.mdx')), + metadata: nativeCapacitor, + }, + { + order: 4, id: 'web-remix', Logo: lazy(async () => import('./web-remix/logo.svg')), Component: lazy(async () => import('./web-remix/README.mdx')), metadata: webRemix, }, { - order: 7, + order: 5, + id: 'native-flutter', + Logo: lazy(async () => import('./native-flutter/logo.svg')), + Component: lazy(async () => import('./native-flutter/README.mdx')), + metadata: nativeFlutter, + }, + { + order: 5, id: 'web-asp-net-core', Logo: lazy(async () => import('./web-asp-net-core/logo.svg')), Component: lazy(async () => import('./web-asp-net-core/README.mdx')), metadata: webAspNetCore, }, { - order: 8, + order: 6, id: 'web-outline', Logo: lazy(async () => import('./web-outline/logo.svg')), Component: lazy(async () => import('./web-outline/README.mdx')), metadata: webOutline, }, - { - order: 9, - id: 'web-gpt-plugin', - Logo: lazy(async () => import('./web-gpt-plugin/logo.svg')), - Component: lazy(async () => import('./web-gpt-plugin/README.mdx')), - metadata: webGptPlugin, - }, ]); export default guides; diff --git a/packages/console/src/assets/docs/guides/m2m-general/config.json b/packages/console/src/assets/docs/guides/m2m-general/config.json new file mode 100644 index 000000000..5a58e475d --- /dev/null +++ b/packages/console/src/assets/docs/guides/m2m-general/config.json @@ -0,0 +1,3 @@ +{ + "order": 1.2 +} \ No newline at end of file diff --git a/packages/console/src/assets/docs/guides/native-android-java/config.json b/packages/console/src/assets/docs/guides/native-android-java/config.json index c435a12c1..504132be0 100644 --- a/packages/console/src/assets/docs/guides/native-android-java/config.json +++ b/packages/console/src/assets/docs/guides/native-android-java/config.json @@ -1,3 +1,3 @@ { - "order": 2 + "order": 3 } diff --git a/packages/console/src/assets/docs/guides/native-android-kt/config.json b/packages/console/src/assets/docs/guides/native-android-kt/config.json index f00075c68..c435a12c1 100644 --- a/packages/console/src/assets/docs/guides/native-android-kt/config.json +++ b/packages/console/src/assets/docs/guides/native-android-kt/config.json @@ -1,3 +1,3 @@ { - "order": 2.1 + "order": 2 } diff --git a/packages/console/src/assets/docs/guides/native-flutter/config.json b/packages/console/src/assets/docs/guides/native-flutter/config.json index 504132be0..7b21bc7d1 100644 --- a/packages/console/src/assets/docs/guides/native-flutter/config.json +++ b/packages/console/src/assets/docs/guides/native-flutter/config.json @@ -1,3 +1,3 @@ { - "order": 3 + "order": 5 } diff --git a/packages/console/src/assets/docs/guides/native-ios-swift/config.json b/packages/console/src/assets/docs/guides/native-ios-swift/config.json index 66ec4e0b1..d01c4333d 100644 --- a/packages/console/src/assets/docs/guides/native-ios-swift/config.json +++ b/packages/console/src/assets/docs/guides/native-ios-swift/config.json @@ -1,3 +1,3 @@ { - "order": 1 + "order": 1.7 } diff --git a/packages/console/src/assets/docs/guides/spa-react/config.json b/packages/console/src/assets/docs/guides/spa-react/config.json index 66ec4e0b1..4721ad2f7 100644 --- a/packages/console/src/assets/docs/guides/spa-react/config.json +++ b/packages/console/src/assets/docs/guides/spa-react/config.json @@ -1,3 +1,3 @@ { - "order": 1 + "order": 1.1 } diff --git a/packages/console/src/assets/docs/guides/spa-vanilla/config.json b/packages/console/src/assets/docs/guides/spa-vanilla/config.json index 504132be0..c435a12c1 100644 --- a/packages/console/src/assets/docs/guides/spa-vanilla/config.json +++ b/packages/console/src/assets/docs/guides/spa-vanilla/config.json @@ -1,3 +1,3 @@ { - "order": 3 + "order": 2 } diff --git a/packages/console/src/assets/docs/guides/spa-vue/config.json b/packages/console/src/assets/docs/guides/spa-vue/config.json index c435a12c1..ca3d65f23 100644 --- a/packages/console/src/assets/docs/guides/spa-vue/config.json +++ b/packages/console/src/assets/docs/guides/spa-vue/config.json @@ -1,3 +1,3 @@ { - "order": 2 + "order": 1.6 } diff --git a/packages/console/src/assets/docs/guides/web-asp-net-core/config.json b/packages/console/src/assets/docs/guides/web-asp-net-core/config.json index 88177e1ec..7b21bc7d1 100644 --- a/packages/console/src/assets/docs/guides/web-asp-net-core/config.json +++ b/packages/console/src/assets/docs/guides/web-asp-net-core/config.json @@ -1,3 +1,3 @@ { - "order": 7 + "order": 5 } diff --git a/packages/console/src/assets/docs/guides/web-express/config.json b/packages/console/src/assets/docs/guides/web-express/config.json index c435a12c1..228d0926b 100644 --- a/packages/console/src/assets/docs/guides/web-express/config.json +++ b/packages/console/src/assets/docs/guides/web-express/config.json @@ -1,3 +1,3 @@ { - "order": 2 + "order": 1.2 } diff --git a/packages/console/src/assets/docs/guides/web-go/config.json b/packages/console/src/assets/docs/guides/web-go/config.json index 504132be0..dfe20f04f 100644 --- a/packages/console/src/assets/docs/guides/web-go/config.json +++ b/packages/console/src/assets/docs/guides/web-go/config.json @@ -1,3 +1,3 @@ { - "order": 3 + "order": 1.3 } diff --git a/packages/console/src/assets/docs/guides/web-gpt-plugin/config.json b/packages/console/src/assets/docs/guides/web-gpt-plugin/config.json index f24b1f1d7..cd39155a7 100644 --- a/packages/console/src/assets/docs/guides/web-gpt-plugin/config.json +++ b/packages/console/src/assets/docs/guides/web-gpt-plugin/config.json @@ -1,3 +1,3 @@ { - "order": 9 + "order": 1.5 } diff --git a/packages/console/src/assets/docs/guides/web-java/config.json b/packages/console/src/assets/docs/guides/web-java/config.json new file mode 100644 index 000000000..ca9f59b2e --- /dev/null +++ b/packages/console/src/assets/docs/guides/web-java/config.json @@ -0,0 +1,3 @@ +{ + "order": 1.4 +} \ No newline at end of file diff --git a/packages/console/src/assets/docs/guides/web-outline/config.json b/packages/console/src/assets/docs/guides/web-outline/config.json index c76b77fa3..61a30569e 100644 --- a/packages/console/src/assets/docs/guides/web-outline/config.json +++ b/packages/console/src/assets/docs/guides/web-outline/config.json @@ -1,3 +1,3 @@ { - "order": 8 + "order": 6 } diff --git a/packages/console/src/assets/docs/guides/web-php/config.json b/packages/console/src/assets/docs/guides/web-php/config.json index 7b21bc7d1..c435a12c1 100644 --- a/packages/console/src/assets/docs/guides/web-php/config.json +++ b/packages/console/src/assets/docs/guides/web-php/config.json @@ -1,3 +1,3 @@ { - "order": 5 + "order": 2 } diff --git a/packages/console/src/assets/docs/guides/web-python/config.json b/packages/console/src/assets/docs/guides/web-python/config.json index 8ab102f71..504132be0 100644 --- a/packages/console/src/assets/docs/guides/web-python/config.json +++ b/packages/console/src/assets/docs/guides/web-python/config.json @@ -1,3 +1,3 @@ { - "order": 4 + "order": 3 } diff --git a/packages/console/src/assets/docs/guides/web-remix/config.json b/packages/console/src/assets/docs/guides/web-remix/config.json index 61a30569e..8ab102f71 100644 --- a/packages/console/src/assets/docs/guides/web-remix/config.json +++ b/packages/console/src/assets/docs/guides/web-remix/config.json @@ -1,3 +1,3 @@ { - "order": 6 + "order": 4 }