11import "iconify-icon" ;
2+ import { onMounted } from "vue" ;
23import type { RouteLocationNormalized } from "vue-router" ;
34import { defineClientConfig , useRoute } from 'vuepress/client' ;
45import CloudBanner from "./components/CloudBanner.vue" ;
@@ -120,50 +121,33 @@ export default defineClientConfig({
120121 addFixedRoute ( `/clients/grpc/:pathMatch(.*)*` , "/clients/" ) ;
121122
122123 addDynamicRoute ( `/clients/${ clients } /latest/:pathMatch(.*)*` , to => {
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 } ` ;
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 } ` ;
128126 } ) ;
129127 addDynamicRoute ( `/clients/${ clients } /latest` , to => {
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 } ` ;
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 } ` ;
135130 } ) ;
136131 addDynamicRoute ( `/clients/${ clients } /legacy/:version` , to => {
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 } ` ;
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 } ` ;
143135 } ) ;
144136 addDynamicRoute ( `/clients/${ clients } /legacy` , to => {
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 } ` ;
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 } ` ;
150139 } )
151140 addDynamicRoute ( `/clients/${ clients } /:version` , to => {
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 } ` ;
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 } ` ;
158144 } ) ;
159145 addDynamicRoute ( `/clients/${ clients } ` , to => {
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 } ` ;
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 } ` ;
165148 } )
166149
150+
167151 // Add fixed routes for server versions because they don't use the same sidebar structure as the other versions
168152 addFixedRoute ( "/server/v22.10" , "/server/v22.10/introduction.html" ) ;
169153 addFixedRoute ( "/server/v5" , "/server/v5/introduction.html" ) ;
@@ -182,9 +166,10 @@ export default defineClientConfig({
182166 version : esData ?. version ,
183167 category : esData ?. category ,
184168 } ) ;
185- if ( window && window . posthog ) {
169+ const a = window . analytics ;
170+ if ( a ) {
186171 setTimeout ( ( ) => {
187- window . posthog . capture ( '$pageview' , {
172+ a . page ( {
188173 site : "docs" ,
189174 url : window . location . origin + to . fullPath ,
190175 title : to . meta . t ,
@@ -216,4 +201,11 @@ export default defineClientConfig({
216201 } ) ;
217202 router . beforeEach ( ( to , from ) => leave ( to , from ) ) ;
218203 } ,
204+ setup ( ) {
205+ onMounted ( ( ) => {
206+ const route = useRoute ( ) ;
207+ if ( route . path !== "/" ) ;
208+ } ) ;
209+
210+ } ,
219211} ) ;
0 commit comments