Commit 60c3578b70

60c3578b70fa7f49d26843e723d56966b607e59c

parent: 4cc7597fe7

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-07-30 07:09 UTC

Update Search.vue

Layout: unified · split

docs/.vitepress/theme/components/search/Search.vue +11 −2
@@ -779,8 +779,17 @@ function buildDocExcerpt(docId: string): Promise<void> {
779 const headings = div.querySelectorAll('h1, h2, h3, h4, h5, h6') 779 const headings = div.querySelectorAll('h1, h2, h3, h4, h5, h6')
780 headings.forEach((heading) => { 780 headings.forEach((heading) => {
781 const href = heading.querySelector('a')?.getAttribute('href') 781 const href = heading.querySelector('a')?.getAttribute('href')
782 const anchor = href?.startsWith('#') && href.slice(1) 782 const hashIndex = href?.indexOf('#') ?? -1
783 const anchor = hashIndex >= 0 ? href!.slice(hashIndex + 1) : ''
783 if (!anchor) return 784 if (!anchor) return
785
786 const collapsible = heading.closest('details.custom-block') as HTMLDetailsElement | null
787 if (collapsible) {
788 collapsible.open = true
789 map.set(anchor, collapsible.outerHTML)
790 return
791 }
792
784 let html = '' 793 let html = ''
785 let node = heading as Element 794 let node = heading as Element
786 while ((node = node.nextElementSibling!) && !/^h[1-6]$/i.test(node.tagName)) { 795 while ((node = node.nextElementSibling!) && !/^h[1-6]$/i.test(node.tagName)) {
@@ -1749,4 +1758,4 @@ svg {
1749 text-decoration: underline; 1758 text-decoration: underline;
1750 text-underline-offset: 2px; 1759 text-underline-offset: 2px;
1751} 1760}
1752</style> 1761</style>\ No newline at end of file