Commit 7d4b1df360

7d4b1df360a03824ee5d5b69f5ab89b76ce174a1

parent: 4c139805d1

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-06-01 16:06 UTC

Update Layout.vue

Layout: unified · split

docs/.vitepress/theme/Layout.vue +15 −4
@@ -157,6 +157,13 @@ const openCollapsibles = async (target: HTMLElement) => {
157157 if (tagName.length === 2 && tagName[0] === 'H') {
158158 const level = +tagName[1]
159159 if (level >= 1 && level <= 6) {
160 const terms = getSearchTerms(searchQuery)
161 const detailsContainsTerms = (d: HTMLElement) => {
162 if (!terms.length) return false
163 const text = (d.textContent ?? '').toLowerCase()
164 return terms.every((term) => text.includes(term))
165 }
166
160167 let sibling = target.nextElementSibling
161168
162169 while (sibling) {
@@ -167,14 +174,18 @@ const openCollapsibles = async (target: HTMLElement) => {
167174 ) break
168175
169176 if (siblingTag === 'DETAILS') {
170 ;(sibling as HTMLDetailsElement).open = true
171 if (scrollTarget === target) scrollTarget = sibling as HTMLElement
177 if (detailsContainsTerms(sibling as HTMLElement)) {
178 ;(sibling as HTMLDetailsElement).open = true
179 if (scrollTarget === target) scrollTarget = sibling as HTMLElement
180 }
172181 }
173182
174183 const nested = sibling.getElementsByTagName('details')
175184 for (let i = 0, len = nested.length; i < len; i++) {
176 nested[i].open = true
177 if (scrollTarget === target) scrollTarget = nested[i]
185 if (detailsContainsTerms(nested[i])) {
186 nested[i].open = true
187 if (scrollTarget === target) scrollTarget = nested[i]
188 }
178189 }
179190
180191 sibling = sibling.nextElementSibling