@@ -18,8 +18,28 @@ const Dropdown = (props: { location: Location; isMobile: boolean }) => {
18
18
19
19
useEffect ( ( ) => {
20
20
const currentPath = location . pathname ;
21
+
22
+ // First check if we're on a versioned path
23
+ const versionFromPath = options . find (
24
+ ( option ) =>
25
+ option . link !== ' ' &&
26
+ option . link !== '' &&
27
+ ( currentPath . includes ( `/${ option . link } ` ) ||
28
+ currentPath . includes (
29
+ `/${ option . link . replace ( / \. / g, '-' ) } ` ,
30
+ ) ) ,
31
+ ) ;
32
+
33
+ if ( versionFromPath ) {
34
+ setCurrentVersion ( versionFromPath ) ;
35
+ return ;
36
+ }
37
+
38
+ // Check for latest version paths
21
39
if (
22
40
currentPath === '/' ||
41
+ currentPath === '/docs' ||
42
+ currentPath === '/docs/' ||
23
43
currentPath . startsWith ( '/introduction' ) ||
24
44
! currentPath . includes ( '-' )
25
45
) {
@@ -32,18 +52,7 @@ const Dropdown = (props: { location: Location; isMobile: boolean }) => {
32
52
}
33
53
}
34
54
35
- const versionFromPath = options . find (
36
- ( option ) =>
37
- option . link !== ' ' &&
38
- option . link !== '' &&
39
- currentPath . includes ( option . link ) ,
40
- ) ;
41
-
42
- if ( versionFromPath ) {
43
- setCurrentVersion ( versionFromPath ) ;
44
- return ;
45
- }
46
-
55
+ // Check in /docs/ path
47
56
if ( currentPath . startsWith ( '/docs/' ) ) {
48
57
const pathParts = currentPath . split ( '/' ) ;
49
58
if ( pathParts . length >= 3 ) {
@@ -55,7 +64,10 @@ const Dropdown = (props: { location: Location; isMobile: boolean }) => {
55
64
const optionPath = option . link . startsWith ( '/' )
56
65
? option . link . substring ( 1 )
57
66
: option . link ;
58
- return optionPath === versionPathInDocs ;
67
+ return (
68
+ optionPath === versionPathInDocs ||
69
+ optionPath . replace ( / \. / g, '-' ) === versionPathInDocs
70
+ ) ;
59
71
} ) ;
60
72
if ( matchingVersion ) {
61
73
setCurrentVersion ( matchingVersion ) ;
@@ -64,6 +76,7 @@ const Dropdown = (props: { location: Location; isMobile: boolean }) => {
64
76
}
65
77
}
66
78
79
+ // Fallback to query params or localStorage
67
80
const params = new URLSearchParams ( location . search ) ;
68
81
const version =
69
82
params . get ( 'version' ) || localStorage . getItem ( 'version' ) ;
0 commit comments