File tree Expand file tree Collapse file tree 1 file changed +5
-10
lines changed
src/client/theme-default/composables Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,9 @@ export function useNavLink(item: DefaultTheme.NavItemWithLink) {
1313 const props = computed ( ( ) => {
1414 return {
1515 class : {
16- active :
17- normalizePath ( withBase ( item . link ) ) === normalizePath ( route . path ) ,
16+ active : normalizePath ( route . path ) . startsWith (
17+ normalizePath ( withBase ( item . link ) )
18+ ) ,
1819 isExternal
1920 } ,
2021 href : isExternal ? item . link : withBase ( item . link ) ,
@@ -31,14 +32,8 @@ export function useNavLink(item: DefaultTheme.NavItemWithLink) {
3132}
3233
3334function normalizePath ( path : string ) : string {
34- path = path
35+ return path
3536 . replace ( / # .* $ / , '' )
3637 . replace ( / \? .* $ / , '' )
37- . replace ( / \. h t m l $ / , '' )
38-
39- if ( path . endsWith ( '/' ) ) {
40- path += 'index'
41- }
42-
43- return path
38+ . replace ( / \. ( h t m l | m d ) $ / , '' )
4439}
You can’t perform that action at this time.
0 commit comments