11import "iconify-icon" ;
2- import { onMounted } from "vue" ;
32import type { RouteLocationNormalized } from "vue-router" ;
43import { defineClientConfig , useRoute } from 'vuepress/client' ;
54import CloudBanner from "./components/CloudBanner.vue" ;
@@ -121,33 +120,50 @@ export default defineClientConfig({
121120 addFixedRoute ( `/clients/grpc/:pathMatch(.*)*` , "/clients/" ) ;
122121
123122 addDynamicRoute ( `/clients/${ clients } /latest/:pathMatch(.*)*` , to => {
124- const latestVersion = __VERSIONS__ . all . find ( x => x . id === `${ to . params . lang } -client` ) ?. versions [ 0 ]
125- return `/clients/${ to . params . lang } /${ latestVersion ?. version } /${ to . params . pathMatch } ` ;
123+ const latestVersion = __VERSIONS__ . all . find ( x => x . id === `${ to . params . lang } -client` ) ?. versions [ 0 ]
124+ if ( ! latestVersion ?. version ) {
125+ return `/clients/` ;
126+ }
127+ return `/clients/${ to . params . lang } /${ latestVersion ?. version } /${ to . params . pathMatch } ` ;
126128 } ) ;
127129 addDynamicRoute ( `/clients/${ clients } /latest` , to => {
128- const latestVersion = __VERSIONS__ . all . find ( x => x . id === `${ to . params . lang } -client` ) ?. versions [ 0 ]
129- return `/clients/${ to . params . lang } /${ latestVersion ?. version } /${ latestVersion ?. startPage } ` ;
130+ const latestVersion = __VERSIONS__ . all . find ( x => x . id === `${ to . params . lang } -client` ) ?. versions ?. [ 0 ] ;
131+ if ( ! latestVersion ?. version || ! latestVersion ?. startPage ) {
132+ return `/clients/` ;
133+ }
134+ return `/clients/${ to . params . lang } /${ latestVersion . version } /${ latestVersion . startPage } ` ;
130135 } ) ;
131136 addDynamicRoute ( `/clients/${ clients } /legacy/:version` , to => {
132- const version = to . params . version ;
133- const latestVersion = __VERSIONS__ . all . find ( x => x . id === `${ to . params . lang } -client` ) ?. versions . find ( v => v . path === `legacy/${ version } ` )
134- return `/clients/${ to . params . lang } /legacy/${ to . params . version } /${ latestVersion ?. startPage } ` ;
137+ const version = to . params . version ;
138+ const latestVersion = __VERSIONS__ . all . find ( x => x . id === `${ to . params . lang } -client` ) ?. versions . find ( v => v . path === `legacy/${ version } ` )
139+ if ( ! latestVersion ?. version || ! latestVersion ?. startPage ) {
140+ return `/clients/` ;
141+ }
142+ return `/clients/${ to . params . lang } /legacy/${ to . params . version } /${ latestVersion ?. startPage } ` ;
135143 } ) ;
136144 addDynamicRoute ( `/clients/${ clients } /legacy` , to => {
137- const latestVersion = __VERSIONS__ . all . find ( x => x . id === `${ to . params . lang } -client` ) ?. versions . find ( v => v . path . startsWith ( 'legacy/' ) )
138- return `/clients/${ to . params . lang } /${ latestVersion ?. path } /${ latestVersion ?. startPage } ` ;
145+ const latestVersion = __VERSIONS__ . all . find ( x => x . id === `${ to . params . lang } -client` ) ?. versions . find ( v => v . path . startsWith ( 'legacy/' ) )
146+ if ( ! latestVersion ?. version || ! latestVersion ?. startPage ) {
147+ return `/clients/` ;
148+ }
149+ return `/clients/${ to . params . lang } /${ latestVersion ?. path } /${ latestVersion ?. startPage } ` ;
139150 } )
140151 addDynamicRoute ( `/clients/${ clients } /:version` , to => {
141- const version = to . params . version ;
142- const latestVersion = __VERSIONS__ . all . find ( x => x . id === `${ to . params . lang } -client` ) ?. versions . find ( v => v . path === version )
143- return `/clients/${ to . params . lang } /${ version } /${ latestVersion ?. startPage } ` ;
152+ const version = to . params . version ;
153+ const latestVersion = __VERSIONS__ . all . find ( x => x . id === `${ to . params . lang } -client` ) ?. versions . find ( v => v . path === version )
154+ if ( ! latestVersion ?. version || ! latestVersion ?. startPage ) {
155+ return `/clients/` ;
156+ }
157+ return `/clients/${ to . params . lang } /${ version } /${ latestVersion ?. startPage } ` ;
144158 } ) ;
145159 addDynamicRoute ( `/clients/${ clients } ` , to => {
146- const latestVersion = __VERSIONS__ . all . find ( x => x . id === `${ to . params . lang } -client` ) ?. versions [ 0 ]
147- return `/clients/${ to . params . lang } /${ latestVersion ?. path } /${ latestVersion ?. startPage } ` ;
160+ const latestVersion = __VERSIONS__ . all . find ( x => x . id === `${ to . params . lang } -client` ) ?. versions [ 0 ]
161+ if ( ! latestVersion ?. version || ! latestVersion ?. startPage ) {
162+ return `/clients/` ;
163+ }
164+ return `/clients/${ to . params . lang } /${ latestVersion ?. path } /${ latestVersion ?. startPage } ` ;
148165 } )
149166
150-
151167 // Add fixed routes for server versions because they don't use the same sidebar structure as the other versions
152168 addFixedRoute ( "/server/v22.10" , "/server/v22.10/introduction.html" ) ;
153169 addFixedRoute ( "/server/v5" , "/server/v5/introduction.html" ) ;
@@ -200,11 +216,4 @@ export default defineClientConfig({
200216 } ) ;
201217 router . beforeEach ( ( to , from ) => leave ( to , from ) ) ;
202218 } ,
203- setup ( ) {
204- onMounted ( ( ) => {
205- const route = useRoute ( ) ;
206- if ( route . path !== "/" ) ;
207- } ) ;
208-
209- } ,
210219} ) ;
0 commit comments