Skip to content

Commit

Permalink
fix: fix DocSearch version
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Dec 16, 2024
1 parent 4c492fe commit b3f82f5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/.vuepress/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
import { defineDocSearchConfig } from '@vuepress/plugin-docsearch/client';
import { computed } from 'vue';
import { defineClientConfig, usePageData } from 'vuepress/client';
import DocSearch from './components/DocSearch.vue';
import { getDocVersion } from './utils/index.js';

export default defineClientConfig({
enhance: ({ app }) => {
app.component('DocSearch', DocSearch);
},
setup() {
const pageData = usePageData();

Expand Down
31 changes: 31 additions & 0 deletions src/.vuepress/components/DocSearch.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->

<script setup lang="ts">
import { usePageData } from 'vuepress/client';
import { getDocVersion } from '../utils/index.js';
import { computed } from 'vue';

const pageData = usePageData();

const docVersion = computed(() => getDocVersion(pageData.value.path));
</script>

<template>
<SearchBox :key="docVersion" />
</template>
2 changes: 1 addition & 1 deletion src/.vuepress/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default hopeTheme(
navbarLayout: {
start: ['Brand'],
center: [],
end: ['Search', 'Links', 'Language', 'Outlook', 'Repo'],
end: ['DocSearch', 'Links', 'Language', 'Outlook', 'Repo'],
},

locales: {
Expand Down

0 comments on commit b3f82f5

Please sign in to comment.