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) => {
157 if (tagName.length === 2 && tagName[0] === 'H') { 157 if (tagName.length === 2 && tagName[0] === 'H') {
158 const level = +tagName[1] 158 const level = +tagName[1]
159 if (level >= 1 && level <= 6) { 159 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
160 let sibling = target.nextElementSibling 167 let sibling = target.nextElementSibling
161 168
162 while (sibling) { 169 while (sibling) {
@@ -167,14 +174,18 @@ const openCollapsibles = async (target: HTMLElement) => {
167 ) break 174 ) break
168 175
169 if (siblingTag === 'DETAILS') { 176 if (siblingTag === 'DETAILS') {
170 ;(sibling as HTMLDetailsElement).open = true 177 if (detailsContainsTerms(sibling as HTMLElement)) {
171 if (scrollTarget === target) scrollTarget = sibling as HTMLElement 178 ;(sibling as HTMLDetailsElement).open = true
179 if (scrollTarget === target) scrollTarget = sibling as HTMLElement
180 }
172 } 181 }
173 182
174 const nested = sibling.getElementsByTagName('details') 183 const nested = sibling.getElementsByTagName('details')
175 for (let i = 0, len = nested.length; i < len; i++) { 184 for (let i = 0, len = nested.length; i < len; i++) {
176 nested[i].open = true 185 if (detailsContainsTerms(nested[i])) {
177 if (scrollTarget === target) scrollTarget = nested[i] 186 nested[i].open = true
187 if (scrollTarget === target) scrollTarget = nested[i]
188 }
178 } 189 }
179 190
180 sibling = sibling.nextElementSibling 191 sibling = sibling.nextElementSibling