Skip to content

Commit e295160

Browse files
committed
fix(theme): fix meta key not showing on search button
1 parent 0a387dd commit e295160

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/client/theme-default/components/VPNavBarSearch.vue

+10-1
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,19 @@ if (!__ALGOLIA__ && theme.value.offlineSearch) {
113113
}
114114
})
115115
}
116+
117+
const metaKey = ref(`'Meta'`)
118+
119+
onMounted(() => {
120+
// meta key detect (same logic as in @docsearch/js)
121+
metaKey.value = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)
122+
? `'⌘'`
123+
: `'Ctrl'`
124+
})
116125
</script>
117126

118127
<template>
119-
<div class="VPNavBarSearch">
128+
<div class="VPNavBarSearch" :style="{ '--vp-meta-key': metaKey }">
120129
<template v-if="theme.algolia">
121130
<VPAlgoliaSearchBox v-if="loaded" :algolia="theme.algolia" />
122131

src/client/theme-default/components/VPNavBarSearchButton.vue

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
<script lang="ts" setup>
2-
import { onMounted, ref } from 'vue'
3-
42
defineProps<{
53
placeholder: string
64
}>()
7-
8-
const metaKey = ref(`'Meta'`)
9-
10-
onMounted(() => {
11-
// meta key detect (same logic as in @docsearch/js)
12-
metaKey.value = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)
13-
? `'⌘'`
14-
: `'Ctrl'`
15-
})
165
</script>
176

187
<template>
@@ -210,7 +199,7 @@ onMounted(() => {
210199
}
211200
212201
.DocSearch-Button .DocSearch-Button-Key:first-child:after {
213-
content: v-bind(metaKey);
202+
content: var(--vp-meta-key);
214203
font-size: 12px;
215204
letter-spacing: normal;
216205
color: var(--docsearch-muted-color);

0 commit comments

Comments
 (0)