Commit ee7341d567
Unsigned
Layout: unified · split
docs/.vitepress/theme/components/search/Search.vue +23 −1
| @@ -928,7 +928,28 @@ function centerExcerpts() { | ||
| 928 | 928 | const excerpts = el.value?.querySelectorAll('.result .excerpt') ?? [] |
| 929 | 929 | for (let i = 0; i < excerpts.length; i++) { |
| 930 | 930 | const excerptElement = excerpts[i] as HTMLElement |
| 931 | const markNode = excerptElement.querySelector('mark[data-markjs="true"]') as HTMLElement | null | |
| 931 | ||
| 932 | const resultEl = excerptElement.closest('.result') as HTMLElement | null | |
| 933 | const linkTitle = resultEl?.dataset?.linkTitle | |
| 934 | ||
| 935 | let markNode: HTMLElement | null | |
| 936 | if (linkTitle) { | |
| 937 | const links = excerptElement.querySelectorAll('a') | |
| 938 | let targetLink: HTMLAnchorElement | null = null | |
| 939 | const normalizedTitle = linkTitle.trim().toLowerCase() | |
| 940 | for (const link of links) { | |
| 941 | if (link.textContent?.trim().toLowerCase() === normalizedTitle) { | |
| 942 | targetLink = link | |
| 943 | break | |
| 944 | } | |
| 945 | } | |
| 946 | markNode = targetLink | |
| 947 | ? (targetLink.querySelector('mark[data-markjs="true"]') as HTMLElement | null) | |
| 948 | : (excerptElement.querySelector('mark[data-markjs="true"]') as HTMLElement | null) | |
| 949 | } else { | |
| 950 | markNode = excerptElement.querySelector('mark[data-markjs="true"]') as HTMLElement | null | |
| 951 | } | |
| 952 | ||
| 932 | 953 | if (!markNode) continue |
| 933 | 954 | const viewportHeight = excerptElement.clientHeight || 84 |
| 934 | 955 | let offset = 0 |
| @@ -1385,6 +1406,7 @@ function onMouseMove(e: MouseEvent) { | ||
| 1385 | 1406 | @focusin="selectedIndex = index + 1" |
| 1386 | 1407 | @click="onResultClick(p)" |
| 1387 | 1408 | :data-index="index + 1" |
| 1409 | :data-link-title="p._linkIndex != null ? p.title : undefined" | |
| 1388 | 1410 | > |
| 1389 | 1411 | <div> |
| 1390 | 1412 | <div class="titles"> |