fix(theme): vitepress data not properly injected in app when use localSearch (#2299)

pull/2301/head
zRains 2 years ago committed by GitHub
parent 1610b88daf
commit 69c7646daf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -30,6 +30,7 @@ import { pathToFile } from '../../app/utils'
import { slash } from '../../shared'
import { useData } from '../composables/data'
import { createTranslate } from '../support/translation'
import { dataSymbol } from '../../app/data'
defineProps<{
placeholder: string
@ -62,8 +63,8 @@ interface Result {
text?: string
}
const { localeIndex, theme } = useData()
const vitePressData = useData()
const { localeIndex, theme } = vitePressData
const searchIndex = computedAsync(async () =>
markRaw(
MiniSearch.loadJSON<Result>(
@ -153,6 +154,7 @@ debouncedWatch(
const app = createApp(comp)
// Silence warnings about missing components
app.config.warnHandler = () => {}
app.provide(dataSymbol, vitePressData)
const div = document.createElement('div')
app.mount(div)
const sections = div.innerHTML.split(headingRegex)

Loading…
Cancel
Save