Skip to content

Commit

Permalink
fix(theme-default): fix header provide
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Jan 15, 2025
1 parent fc98b5e commit 2ee49d3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions themes/theme-default/src/client/composables/useHeaders.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useThemeLocaleData } from '@theme/useThemeData'
import type { MenuItem } from '@vuepress/helper/client'
import { getHeaders } from '@vuepress/helper/client'
import { watchImmediate } from '@vueuse/core'
import { injectLocal, provideLocal, watchImmediate } from '@vueuse/core'
import type { InjectionKey, Ref } from 'vue'
import { computed, inject, onMounted, provide, ref } from 'vue'
import { computed, onMounted, ref } from 'vue'
import { usePageFrontmatter, useRoutePath } from 'vuepress/client'
import type { DefaultThemeNormalPageFrontmatter } from '../../shared/index.js'

Expand All @@ -15,7 +15,7 @@ export const headersSymbol: InjectionKey<HeadersRef> = Symbol('headers')
* Inject headers
*/
export const useHeaders = (): HeadersRef => {
const headers = inject(headersSymbol)
const headers = injectLocal(headersSymbol)

if (!headers) {
throw new Error('useHeaders() is called without provider.')
Expand Down Expand Up @@ -45,7 +45,7 @@ export const setupHeaders = (): void => {
})
}

provide(headersSymbol, headersRef)
provideLocal(headersSymbol, headersRef)

onMounted(() => {
watchImmediate([levels, routePath], updateHeaders)
Expand Down

0 comments on commit 2ee49d3

Please sign in to comment.