From 0fc32a10b2e35b08c75bc462bb91a0c6d74d2981 Mon Sep 17 00:00:00 2001 From: casyalex Date: Mon, 20 Jun 2022 16:46:19 +0800 Subject: [PATCH 1/6] feat: add active style to VPFlyout, NavbarGroup can active now. --- docs/.vitepress/config.ts | 6 ++++- .../theme-default/components/VPFlyout.vue | 23 +++++++------------ .../components/VPNavBarMenuGroup.vue | 12 ++++++++-- types/default-theme.d.ts | 6 +++++ 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 23eeac47de98..d8ea0354e9f3 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -44,11 +44,15 @@ export default defineConfig({ function nav() { return [ - { text: 'Guide', link: '/guide/what-is-vitepress', activeMatch: '/guide/' }, + // { text: 'Guide', link: '/guide/what-is-vitepress', activeMatch: '/guide/' }, { text: 'Configs', link: '/config/introduction', activeMatch: '/config/' }, { text: 'Changelog', link: 'https://github.com/vuejs/vitepress/blob/main/CHANGELOG.md' + },{ + text:'Gruop Nav', + activeMatch: '/guide/', + items: [{ text: 'Guide', link: '/guide/what-is-vitepress', },] } ] } diff --git a/src/client/theme-default/components/VPFlyout.vue b/src/client/theme-default/components/VPFlyout.vue index f4a3c98201bb..e204dc0daba0 100644 --- a/src/client/theme-default/components/VPFlyout.vue +++ b/src/client/theme-default/components/VPFlyout.vue @@ -23,20 +23,9 @@ function onBlur() { \ No newline at end of file diff --git a/types/default-theme.d.ts b/types/default-theme.d.ts index 945773672e6f..26c02dfda323 100644 --- a/types/default-theme.d.ts +++ b/types/default-theme.d.ts @@ -94,6 +94,12 @@ export namespace DefaultTheme { export interface NavItemWithChildren { text?: string items: (NavItemChildren | NavItemWithLink)[] + + /** + * `activeMatch` is expected to be a regex string. We can't use actual + * RegExp object here because it isn't serializable + */ + activeMatch?: string } // image ----------------------------------------------------------------------- From fa65c49a3f99a6499df6a82084b666cd4900b0c1 Mon Sep 17 00:00:00 2001 From: casyalex Date: Mon, 20 Jun 2022 18:53:57 +0800 Subject: [PATCH 2/6] chore: revert unnecessary change --- docs/.vitepress/config.ts | 8 ++------ .../theme-default/components/VPFlyout.vue | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index d8ea0354e9f3..5bbcd727301f 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -44,16 +44,12 @@ export default defineConfig({ function nav() { return [ - // { text: 'Guide', link: '/guide/what-is-vitepress', activeMatch: '/guide/' }, + { text: 'Guide', link: '/guide/what-is-vitepress', activeMatch: '/guide/' }, { text: 'Configs', link: '/config/introduction', activeMatch: '/config/' }, { text: 'Changelog', link: 'https://github.com/vuejs/vitepress/blob/main/CHANGELOG.md' - },{ - text:'Gruop Nav', - activeMatch: '/guide/', - items: [{ text: 'Guide', link: '/guide/what-is-vitepress', },] - } + }, ] } diff --git a/src/client/theme-default/components/VPFlyout.vue b/src/client/theme-default/components/VPFlyout.vue index e204dc0daba0..fc10b82aa530 100644 --- a/src/client/theme-default/components/VPFlyout.vue +++ b/src/client/theme-default/components/VPFlyout.vue @@ -23,9 +23,20 @@ function onBlur() { \ No newline at end of file + From ae6bcc5b2bb0e03148514b85833d0df3e18aa27e Mon Sep 17 00:00:00 2001 From: Kia King Ishii Date: Wed, 22 Jun 2022 00:33:09 +0900 Subject: [PATCH 6/6] docs: add docs --- docs/config/theme-configs.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/config/theme-configs.md b/docs/config/theme-configs.md index 37564b783a7b..4ebfdc8723c1 100644 --- a/docs/config/theme-configs.md +++ b/docs/config/theme-configs.md @@ -83,6 +83,7 @@ type NavItemWithLink = { interface NavItemWithChildren { text?: string items: NavItemWithLink[] + activeMatch?: string } ```