Commit ee7341d567

ee7341d56733fa8d5602cbe9ba6dcfdc8c610324

parent: fdea6c9df8

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-07-29 08:32 UTC

excerpt fix

Layout: unified · split

docs/.vitepress/theme/components/search/Search.vue +23 −1
@@ -928,7 +928,28 @@ function centerExcerpts() {
928928 const excerpts = el.value?.querySelectorAll('.result .excerpt') ?? []
929929 for (let i = 0; i < excerpts.length; i++) {
930930 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
932953 if (!markNode) continue
933954 const viewportHeight = excerptElement.clientHeight || 84
934955 let offset = 0
@@ -1385,6 +1406,7 @@ function onMouseMove(e: MouseEvent) {
13851406 @focusin="selectedIndex = index + 1"
13861407 @click="onResultClick(p)"
13871408 :data-index="index + 1"
1409 :data-link-title="p._linkIndex != null ? p.title : undefined"
13881410 >
13891411 <div>
13901412 <div class="titles">