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) { |
| 1369 | <component |
1369 | <component |
| 1370 | :is="searchMotionLi" |
1370 | :is="searchMotionLi" |
| 1371 | v-for="(p, index) in pagedResults" |
1371 | v-for="(p, index) in pagedResults" |
| 1372 | :key="'normal-' + normalCurrentPage + '-' + p.id" |
1372 | :key="'normal-' + normalCurrentPage + '-' + p.id + (p._linkIndex != null ? '-' + p._linkIndex : '')" |
| 1373 | class="result-layout" |
1373 | class="result-layout" |
| 1374 | :id="'localsearch-item-' + (index + 1)" |
1374 | :id="'localsearch-item-' + (index + 1)" |
| 1375 | :aria-selected="selectedIndex === index + 1 ? 'true' : 'false'" |
1375 | :aria-selected="selectedIndex === index + 1 ? 'true' : 'false'" |
docs/.vitepress/theme/components/search/types.ts
+1
| @@ -30,6 +30,7 @@ export interface Result { |
| 30 | title: string |
30 | title: string |
| 31 | titles: string[] |
31 | titles: string[] |
| 32 | text?: string |
32 | text?: string |
| |
33 | _linkIndex?: number |
| 33 | } |
34 | } |
| 34 | |
35 | |
| 35 | export interface PageGroupCount { |
36 | export interface PageGroupCount { |
docs/.vitepress/theme/workers/searchWorker.ts
+21 −13
| @@ -156,16 +156,16 @@ function getQueryTerms(query: string) { |
| 156 | .filter(Boolean) |
156 | .filter(Boolean) |
| 157 | } |
157 | } |
| 158 | |
158 | |
| 159 | function findMatchingLinkForResult( |
159 | function findMatchingLinksForResult( |
| 160 | result: WorkerSearchResult, |
160 | result: WorkerSearchResult, |
| 161 | query: string |
161 | query: string |
| 162 | ) { |
162 | ) { |
| 163 | const pageId = getPageKey(String(result.id)) |
163 | const pageId = getPageKey(String(result.id)) |
| 164 | const anchor = String(result.id).split('#')[1] ?? '' |
164 | const anchor = String(result.id).split('#')[1] ?? '' |
| 165 | const terms = getQueryTerms(query) |
165 | const terms = getQueryTerms(query) |
| 166 | if (!terms.length) return |
166 | if (!terms.length) return [] |
| 167 | |
167 | |
| 168 | return urlLinks.find((link) => { |
168 | return urlLinks.filter((link) => { |
| 169 | if (link.pageId.replace(/\/$/, '') !== pageId || link.anchor !== anchor) { |
169 | if (link.pageId.replace(/\/$/, '') !== pageId || link.anchor !== anchor) { |
| 170 | return false |
170 | return false |
| 171 | } |
171 | } |
| @@ -181,17 +181,25 @@ function withLinkPathTitles( |
| 181 | ) { |
181 | ) { |
| 182 | if (!urlLinks.length) return results |
182 | if (!urlLinks.length) return results |
| 183 | |
183 | |
| 184 | return results.map((result) => { |
184 | const expanded: WorkerSearchResult[] = [] |
| 185 | const link = findMatchingLinkForResult(result, query) |
185 | for (const result of results) { |
| 186 | if (!link) return result |
186 | const links = findMatchingLinksForResult(result, query) |
| 187 | |
187 | if (!links.length) { |
| 188 | return { |
188 | expanded.push(result) |
| 189 | ...result, |
189 | } else { |
| 190 | title: stripMarkdown(link.linkText), |
190 | for (let i = 0; i < links.length; i++) { |
| 191 | titles: link.titles, |
191 | const link = links[i] |
| 192 | ...(link.tabs?.length ? { tabs: link.tabs } : {}) |
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 | } |
| 193 | } |
200 | } |
| 194 | }) |
201 | } |
| |
202 | return expanded |
| 195 | } |
203 | } |
| 196 | |
204 | |
| 197 | function getTabsForResult(result: WorkerSearchResult) { |
205 | function getTabsForResult(result: WorkerSearchResult) { |