mirror of
https://github.com/imezx/Warp.git
synced 2025-04-25 15:40:02 +00:00
19 lines
563 B
JavaScript
19 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
|
||
|
};
|
||
|
}
|