From 489681117f46a803704b6ec80546a5e787e19df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=BD=E5=AE=81?= Date: Sun, 21 May 2023 15:09:57 +0800 Subject: [PATCH] fix(theme): missing global properties in localSearch (#2396) --- .../theme-default/components/VPLocalSearchBox.vue | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/client/theme-default/components/VPLocalSearchBox.vue b/src/client/theme-default/components/VPLocalSearchBox.vue index 0f7349b3..32b68f96 100644 --- a/src/client/theme-default/components/VPLocalSearchBox.vue +++ b/src/client/theme-default/components/VPLocalSearchBox.vue @@ -161,6 +161,18 @@ debouncedWatch( // Silence warnings about missing components app.config.warnHandler = () => {} app.provide(dataSymbol, vitePressData) + Object.defineProperties(app.config.globalProperties, { + $frontmatter: { + get() { + return vitePressData.frontmatter.value + } + }, + $params: { + get() { + return vitePressData.page.value.params + } + } + }) const div = document.createElement('div') app.mount(div) const sections = div.innerHTML.split(headingRegex)