Commit 60c3578b70
Unsigned
Layout: unified · split
docs/.vitepress/theme/components/search/Search.vue +11 −2
| @@ -779,8 +779,17 @@ function buildDocExcerpt(docId: string): Promise<void> { | ||
| 779 | 779 | const headings = div.querySelectorAll('h1, h2, h3, h4, h5, h6') |
| 780 | 780 | headings.forEach((heading) => { |
| 781 | 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 | 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 | 793 | let html = '' |
| 785 | 794 | let node = heading as Element |
| 786 | 795 | while ((node = node.nextElementSibling!) && !/^h[1-6]$/i.test(node.tagName)) { |
| @@ -1749,4 +1758,4 @@ svg { | ||
| 1749 | 1758 | text-decoration: underline; |
| 1750 | 1759 | text-underline-offset: 2px; |
| 1751 | 1760 | } |
| 1752 | </style> | |
| 1761 | </style> | |
| \ No newline at end of file | ||