mirror of
https://github.com/imezx/Warp.git
synced 2025-04-24 23:20:02 +00:00
18 lines
563 B
JavaScript
18 lines
563 B
JavaScript
import { onContentUpdated } from 'vitepress';
|
|
import { computed, shallowRef } from 'vue';
|
|
import { getHeaders } from '../composables/outline';
|
|
import { useData } from './data';
|
|
export function useLocalNav() {
|
|
const { theme, frontmatter } = useData();
|
|
const headers = shallowRef([]);
|
|
const hasLocalNav = computed(() => {
|
|
return headers.value.length > 0;
|
|
});
|
|
onContentUpdated(() => {
|
|
headers.value = getHeaders(frontmatter.value.outline ?? theme.value.outline);
|
|
});
|
|
return {
|
|
headers,
|
|
hasLocalNav
|
|
};
|
|
}
|