fix(plugin-search): incorrect local search results (#434)
This commit is contained in:
parent
40bbb22487
commit
000299666d
@ -10,6 +10,7 @@ comment: false
|
||||
editLink: false
|
||||
contributors: false
|
||||
changelog: false
|
||||
search: false
|
||||
---
|
||||
|
||||
<!-- @include: ../CHANGELOG.md -->
|
||||
|
||||
@ -8,6 +8,7 @@ readingTime: false
|
||||
editLink: false
|
||||
contributors: false
|
||||
changelog: false
|
||||
search: false
|
||||
---
|
||||
|
||||
<!-- @include: ../CONTRIBUTING.md{2-} -->
|
||||
|
||||
@ -10,6 +10,7 @@ draft: true
|
||||
externalLinkIcon: false
|
||||
contributors: false
|
||||
changelog: false
|
||||
search: false
|
||||
docs:
|
||||
-
|
||||
name: VuePress Plume
|
||||
|
||||
@ -7,6 +7,7 @@ aside: false
|
||||
readingTime: false
|
||||
contributors: false
|
||||
changelog: false
|
||||
search: false
|
||||
---
|
||||
|
||||
:::important 作者的话
|
||||
|
||||
@ -120,7 +120,7 @@ debouncedWatch(
|
||||
// Search
|
||||
results.value = index
|
||||
.search(filterTextValue)
|
||||
.slice(0, 16)
|
||||
// .slice(0, 16)
|
||||
.map((r) => {
|
||||
r.titles = r.titles?.filter(Boolean) || []
|
||||
return r
|
||||
|
||||
@ -13,12 +13,7 @@ const locale = useLocale(toRef(props.locales))
|
||||
<template>
|
||||
<button type="button" class="mini-search mini-search-button" :aria-label="locale.placeholder">
|
||||
<span class="mini-search-button-container">
|
||||
<svg class="mini-search-search-icon" width="20" height="20" viewBox="0 0 20 20" aria-label="search icon">
|
||||
<path
|
||||
d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z"
|
||||
stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
<span class="mini-search-search-icon vpi-mini-search" aria-label="search icon" />
|
||||
<span class="mini-search-button-placeholder">{{ locale.placeholder }}</span>
|
||||
</span>
|
||||
<span class="mini-search-button-keys">
|
||||
@ -76,6 +71,10 @@ const locale = useLocale(toRef(props.locales))
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.mini-search-button .vpi-mini-search {
|
||||
--icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' stroke-width='1.6' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='m14.386 14.386 4.088 4.088-4.088-4.088A7.533 7.533 0 1 1 3.733 3.733a7.533 7.533 0 0 1 10.653 10.653z'/%3E%3C/svg%3E");
|
||||
}
|
||||
|
||||
.mini-search-button .mini-search-search-icon {
|
||||
position: relative;
|
||||
width: 16px;
|
||||
|
||||
@ -118,6 +118,12 @@ async function writeTemp(app: App) {
|
||||
}
|
||||
|
||||
async function indexFile(page: Page, options: SearchIndexOptions['searchOptions']) {
|
||||
if (!page.filePath)
|
||||
return
|
||||
|
||||
if (page.frontmatter?.search === false)
|
||||
return
|
||||
|
||||
// get file metadata
|
||||
const fileId = page.path
|
||||
const locale = page.pathLocale
|
||||
@ -140,7 +146,7 @@ async function indexFile(page: Page, options: SearchIndexOptions['searchOptions'
|
||||
id,
|
||||
text,
|
||||
title: titles.at(-1)!,
|
||||
titles: titles.slice(0, -1),
|
||||
titles: [page.frontmatter.title || page.title, ...titles.slice(0, -1)],
|
||||
}
|
||||
index.add(item)
|
||||
cache.push(item)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user