Commit fdea6c9df8

fdea6c9df8473b926f2ebb8ef350b9bccaf9f15d

parent: 1e50da773d

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-07-28 17:38 UTC

id

Layout: unified · split

docs/.vitepress/theme/components/search/Search.vue +1 −1
@@ -1369,7 +1369,7 @@ function onMouseMove(e: MouseEvent) {
13691369 <component
13701370 :is="searchMotionLi"
13711371 v-for="(p, index) in pagedResults"
1372 :key="'normal-' + normalCurrentPage + '-' + p.id"
1372 :key="'normal-' + normalCurrentPage + '-' + p.id + (p._linkIndex != null ? '-' + p._linkIndex : '')"
13731373 class="result-layout"
13741374 :id="'localsearch-item-' + (index + 1)"
13751375 :aria-selected="selectedIndex === index + 1 ? 'true' : 'false'"
docs/.vitepress/theme/components/search/types.ts +1
@@ -30,6 +30,7 @@ export interface Result {
3030 title: string
3131 titles: string[]
3232 text?: string
33 _linkIndex?: number
3334}
3435
3536export interface PageGroupCount {
docs/.vitepress/theme/workers/searchWorker.ts +21 −13
@@ -156,16 +156,16 @@ function getQueryTerms(query: string) {
156156 .filter(Boolean)
157157}
158158
159function findMatchingLinkForResult(
159function findMatchingLinksForResult(
160160 result: WorkerSearchResult,
161161 query: string
162162) {
163163 const pageId = getPageKey(String(result.id))
164164 const anchor = String(result.id).split('#')[1] ?? ''
165165 const terms = getQueryTerms(query)
166 if (!terms.length) return
166 if (!terms.length) return []
167167
168 return urlLinks.find((link) => {
168 return urlLinks.filter((link) => {
169169 if (link.pageId.replace(/\/$/, '') !== pageId || link.anchor !== anchor) {
170170 return false
171171 }
@@ -181,17 +181,25 @@ function withLinkPathTitles(
181181) {
182182 if (!urlLinks.length) return results
183183
184 return results.map((result) => {
185 const link = findMatchingLinkForResult(result, query)
186 if (!link) return result
187
188 return {
189 ...result,
190 title: stripMarkdown(link.linkText),
191 titles: link.titles,
192 ...(link.tabs?.length ? { tabs: link.tabs } : {})
184 const expanded: WorkerSearchResult[] = []
185 for (const result of results) {
186 const links = findMatchingLinksForResult(result, query)
187 if (!links.length) {
188 expanded.push(result)
189 } else {
190 for (let i = 0; i < links.length; i++) {
191 const link = links[i]
192 expanded.push({
193 ...result,
194 title: stripMarkdown(link.linkText),
195 titles: link.titles,
196 _linkIndex: i,
197 ...(link.tabs?.length ? { tabs: link.tabs } : {})
198 })
199 }
193200 }
194 })
201 }
202 return expanded
195203}
196204
197205function getTabsForResult(result: WorkerSearchResult) {