Skip to content

Commit 54ff69f

Browse files
committed
fix: fix DocSearch version
1 parent 4c492fe commit 54ff69f

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

src/.vuepress/client.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@
1919
import { defineDocSearchConfig } from '@vuepress/plugin-docsearch/client';
2020
import { computed } from 'vue';
2121
import { defineClientConfig, usePageData } from 'vuepress/client';
22+
import DocSearch from './components/DocSearch.vue';
2223
import { getDocVersion } from './utils/index.js';
2324

2425
export default defineClientConfig({
26+
enhance: ({ app }) => {
27+
app.component('DocSearch', DocSearch);
28+
},
2529
setup() {
2630
const pageData = usePageData();
2731

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!--
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
-->
18+
19+
<script setup lang="ts">
20+
import { usePageData } from 'vuepress/client';
21+
import { getDocVersion } from '../utils/index.js';
22+
import { computed } from 'vue';
23+
24+
const pageData = usePageData();
25+
26+
const docVersion = computed(() => getDocVersion(pageData.value.path));
27+
</script>
28+
29+
<template>
30+
<SearchBox :key="docVersion" />
31+
</template>

src/.vuepress/components/PageFooter.vue

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
<script setup lang="ts">
2020
import { useLocaleConfig } from '@vuepress/helper/client';
2121
import { computed } from 'vue';
22-
import { usePageData } from 'vuepress/client';
23-
import { getDocVersion } from '../utils/index.js';
24-
25-
const pageData = usePageData();
26-
27-
const docVersion = computed(() => getDocVersion(pageData.value.path));
2822
2923
const locale = useLocaleConfig({
3024
'/': {
@@ -53,10 +47,6 @@ const copyrightText = computed(() =>
5347

5448
<template>
5549
<footer class="site-footer">
56-
<span
57-
id="doc-version"
58-
style="display: none"
59-
>{{ docVersion }}</span>
6050
<p class="copyright-text">
6151
{{ copyrightText }}
6252
</p>

src/.vuepress/theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default hopeTheme(
3838
navbarLayout: {
3939
start: ['Brand'],
4040
center: [],
41-
end: ['Search', 'Links', 'Language', 'Outlook', 'Repo'],
41+
end: ['DocSearch', 'Links', 'Language', 'Outlook', 'Repo'],
4242
},
4343

4444
locales: {

0 commit comments

Comments
 (0)