fix(theme): prevent sidebar re-render unless there is actual change

closes #2796
pull/2803/head
Divyansh Singh 11 months ago
parent 6960ec1cf6
commit 33962e04eb

@ -35,12 +35,19 @@ export function useSidebar() {
const isOpen = ref(false)
const sidebar = computed(() => {
const _sidebar = computed(() => {
const sidebarConfig = theme.value.sidebar
const relativePath = page.value.relativePath
return sidebarConfig ? getSidebar(sidebarConfig, relativePath) : []
})
const sidebar = ref(_sidebar.value)
watch(_sidebar, (next, prev) => {
if (JSON.stringify(next) !== JSON.stringify(prev))
sidebar.value = _sidebar.value
})
const hasSidebar = computed(() => {
return (
frontmatter.value.sidebar !== false &&

Loading…
Cancel
Save