Skip to content

Commit

Permalink
fix(theme): prevent sidebar re-render unless there is actual change
Browse files Browse the repository at this point in the history
closes #2796
  • Loading branch information
brc-dd committed Aug 16, 2023
1 parent 6960ec1 commit 33962e0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/client/theme-default/composables/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit 33962e0

Please sign in to comment.