Skip to content

Commit

Permalink
🐞 fix(toc): subtitle cannot close toc
Browse files Browse the repository at this point in the history
  • Loading branch information
Big-Cake-jpg committed Jul 12, 2024
1 parent 3402c6a commit c24057b
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"vite-plugin-compression2": "^1.1.2"
},
"devDependencies": {
"@mojojoejo/vite-plugin-purgecss": "^1.1.0",
"esbuild-wasm": "^0.23.0",
"vite-plugin-minify": "^1.5.2"
},
Expand Down
90 changes: 90 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion valaxy-theme-custom/components/_partial/OutlineItem.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<script setup lang="ts">
import type { MenuItem } from "valaxy";
import { defineProps, defineEmits } from "vue";
defineProps<{
headers: MenuItem[];
onClick: (e: MouseEvent) => void;
root?: boolean;
}>();
const emit = defineEmits(['close-menu']);
const handleClick = (e: MouseEvent, link: string) => {
e.preventDefault();
const anchor = link.slice(1);
Expand All @@ -17,6 +20,7 @@ const handleClick = (e: MouseEvent, link: string) => {
behavior: "smooth",
});
}
emit('close-menu');
};
</script>

Expand All @@ -33,7 +37,7 @@ const handleClick = (e: MouseEvent, link: string) => {
{{ title }}
</a>
<template v-if="children?.length">
<OutlineItem :headers="children" :on-click="onClick" />
<OutlineItem :headers="children" @click="handleClick($event, link)" @close-menu="$emit('close-menu')"/>
</template>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { ref } from "vue";
const { headers, handleClick } = useOutline();
const OutlineItemShow = ref(false);
const closeOutline = () => {
OutlineItemShow.value = false;
};
</script>

<template>
Expand All @@ -25,6 +29,7 @@ const OutlineItemShow = ref(false);
:on-click="handleClick"
root
@click="OutlineItemShow = false"
@close-menu="closeOutline"
/>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion valaxy.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import type { ThemeConfig } from "valaxy-theme-custom";
import { addonComponents } from "valaxy-addon-components";
import { addonLightGallery } from "valaxy-addon-lightgallery";
import compression from "vite-plugin-compression2";
import { ViteMinifyPlugin } from 'vite-plugin-minify'
import { ViteMinifyPlugin } from 'vite-plugin-minify';
import pluginPurgeCss from "@mojojoejo/vite-plugin-purgecss";
// import { VitePWA } from "vite-plugin-pwa";
// import { addonMeting } from "valaxy-addon-meting";

Expand Down Expand Up @@ -37,6 +38,9 @@ export default defineValaxyConfig<ThemeConfig>({
minifyJS: true,
removeComments: true,
}),
pluginPurgeCss({
variables: true,
}),
],
},

Expand Down

0 comments on commit c24057b

Please sign in to comment.