docs/.vitepress/theme/Layout.vue
1417 lines · 44070 bytes
1<!--
2 All Rights Reserved
3
4 Copyright (c) 2025 taskylizard
5
6 All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder.
7-->
8<script setup lang="ts">
9import {
10 useEventListener,
11 useStorage,
12 useThrottleFn
13} from '@vueuse/core'
14import { getScrollOffset, useData, useRoute } from 'vitepress'
15import type { DefaultTheme as Theme } from 'vitepress'
16import VPSidebarGroup from 'vitepress/dist/client/theme-default/components/VPSidebarGroup.vue'
17import { getSidebarGroups } from 'vitepress/dist/client/theme-default/support/sidebar'
18import DefaultTheme from 'vitepress/theme'
19import {
20 computed,
21 nextTick,
22 onMounted,
23 onUnmounted,
24 ref,
25 watch,
26 watchEffect
27} from 'vue'
28import { sidebar } from '../configs/constants'
29import { useBookmarks, BOOKMARK_CHANGE_EVENT } from './composables/useBookmarks'
30import AnnouncementPill from './components/AnnouncementPill.vue'
31import SiteFooter from './components/SiteFooter.vue'
32import NotFoundComponent from './components/NotFound.vue'
33import { NolebaseEnhancedReadabilitiesScreenMenu } from './components/settings'
34import NavActions from './components/NavActions.vue'
35import SidebarCard from './components/SidebarCard.vue'
36import { AccentBgStorageKey, AccentBgStrengthStorageKey, AccentColorStorageKey } from './constants'
37import { useEffects } from './composables/useEffects'
38
39const route = useRoute()
40const { frontmatter, isDark, site, theme } = useData()
41const { isBookmarked, toggle: bookmarkToggle } = useBookmarks()
42const { Layout } = DefaultTheme
43
44// Home sidebar menu
45const isHome = computed(() => frontmatter.value.layout === 'home')
46const homeSidebarOpen = ref(false)
47const sidebarRef = ref<HTMLElement | null>(null)
48const homeSidebarGroups = getSidebarGroups(sidebar as any)
49const logoSrc = computed(() =>
50 typeof theme.value.logo === 'string'
51 ? theme.value.logo
52 : theme.value.logo?.src
53)
54
55watch(() => route.path, () => {
56 homeSidebarOpen.value = false
57})
58
59let searchNavigated = false
60let searchQuery = ''
61
62if (!import.meta.env.SSR) {
63 useEventListener(window, 'search-nav', (event) => {
64 searchNavigated = true
65 searchQuery = event instanceof CustomEvent &&
66 typeof event.detail?.query === 'string'
67 ? event.detail.query
68 : ''
69 })
70}
71
72const nextFrame = () =>
73 new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))
74
75const getSearchTerms = (query: string) =>
76 query
77 .toLowerCase()
78 .split(/\s+/)
79 .map((term) => term.trim())
80 .filter(Boolean)
81
82const getTargetByHash = (hash: string) => {
83 const ids = [hash]
84 try {
85 const decoded = decodeURIComponent(hash)
86 if (decoded !== hash) ids.unshift(decoded)
87 } catch {
88 /* keep the raw hash */
89 }
90
91 for (const id of ids) {
92 const target = document.getElementById(id)
93 if (target) return target
94 }
95}
96
97const getScrollTargetForAnchor = (target: HTMLElement) => {
98 if (target.classList.contains('tab-search-heading')) {
99 return target.closest<HTMLElement>('.plugin-tabs') ?? target
100 }
101
102 return target
103}
104
105const TAB_QUERY_PARAM = 't'
106const COLLAPSIBLE_QUERY_PARAM = 'c'
107
108const getRequestedAnchorPath = (param: string) => {
109 const value = new URLSearchParams(window.location.search).get(param)
110 return value
111 ?.split(',')
112 .map((anchor) => anchor.trim())
113 .filter(Boolean) ?? []
114}
115
116const getRequestedTabPath = () => getRequestedAnchorPath(TAB_QUERY_PARAM)
117const getRequestedCollapsiblePath = () =>
118 getRequestedAnchorPath(COLLAPSIBLE_QUERY_PARAM)
119
120const encodeAnchorList = (anchors: string[]) =>
121 anchors.map((anchor) => encodeURIComponent(anchor)).join(',')
122
123const buildUrl = (
124 options: { tabs?: string[]; collapsibles?: string[]; hash?: string } = {}
125) => {
126 const params = new URLSearchParams(window.location.search)
127 const currentTabs = params.get(TAB_QUERY_PARAM)
128 const currentCollapsibles = params.get(COLLAPSIBLE_QUERY_PARAM)
129 params.delete(TAB_QUERY_PARAM)
130 params.delete(COLLAPSIBLE_QUERY_PARAM)
131
132 const tabs = options.tabs ??
133 (currentTabs ? currentTabs.split(',').filter(Boolean) : [])
134 const collapsibles = options.collapsibles ??
135 (currentCollapsibles ? currentCollapsibles.split(',').filter(Boolean) : [])
136
137 const queryParts = [
138 params.toString(),
139 tabs.length ? `${TAB_QUERY_PARAM}=${encodeAnchorList(tabs)}` : '',
140 collapsibles.length
141 ? `${COLLAPSIBLE_QUERY_PARAM}=${encodeAnchorList(collapsibles)}`
142 : ''
143 ].filter(Boolean)
144
145 const hash = options.hash ?? ''
146 return `${window.location.pathname}${
147 queryParts.length ? `?${queryParts.join('&')}` : ''
148 }${hash ? `#${encodeURIComponent(hash)}` : ''}`
149}
150
151const buildUrlWithTabs = (tabs: string[], hash = '') => buildUrl({ tabs, hash })
152
153const getSelectedTabAnchor = (tabs: HTMLElement) =>
154 tabs.querySelector<HTMLButtonElement>(
155 '.plugin-tabs--tab[aria-selected="true"][data-tab-anchor]'
156 )?.dataset.tabAnchor
157
158const getPanelForTabButton = (button: HTMLButtonElement) => {
159 const panelId = button.getAttribute('aria-controls')
160 return panelId ? document.getElementById(panelId) : undefined
161}
162
163const getTabPathForGroup = (tabs: HTMLElement) => {
164 const groups: HTMLElement[] = []
165 let currentTabs: HTMLElement | null = tabs
166
167 while (currentTabs) {
168 groups.unshift(currentTabs)
169 const parentPanel = currentTabs.parentElement?.closest<HTMLElement>(
170 '.plugin-tabs--content[data-tab-anchor]'
171 )
172 currentTabs = parentPanel?.closest<HTMLElement>('.plugin-tabs') ?? null
173 }
174
175 return groups
176 .map((group) => getSelectedTabAnchor(group))
177 .filter((tab): tab is string => Boolean(tab))
178}
179
180const updateQueryForSelectedTab = async (tabs: HTMLElement) => {
181 await nextTick()
182 await nextFrame()
183
184 const tabPath = getTabPathForGroup(tabs)
185 if (!tabPath.length) return
186
187 const collapsibles = getOpenCollapsiblePath(tabs)
188
189 const nextUrl = buildUrl({ tabs: tabPath, collapsibles })
190 const currentUrl =
191 `${window.location.pathname}${window.location.search}${window.location.hash}`
192 if (nextUrl === currentUrl) return
193
194 window.history.pushState(null, '', nextUrl)
195 rewriteAnchorLinks()
196}
197
198const queueTabQueryUpdateForSelection = (target: EventTarget | null) => {
199 if (!(target instanceof HTMLElement)) return
200
201 const button = target.closest<HTMLButtonElement>(
202 '.plugin-tabs--tab[role="tab"]'
203 )
204 const tabs = button?.closest<HTMLElement>('.plugin-tabs')
205 if (tabs) void updateQueryForSelectedTab(tabs)
206}
207
208const COLLAPSIBLE_SELECTOR = 'details[data-collapsible-anchor]'
209
210const getOpenCollapsiblePath = (details: HTMLElement) => {
211 const path: string[] = []
212 let el: HTMLElement | null = details
213
214 while (el) {
215 const current: HTMLElement | null = el.closest(COLLAPSIBLE_SELECTOR)
216 if (!current) break
217
218 if ((current as HTMLDetailsElement).open) {
219 const anchor = current.dataset.collapsibleAnchor
220 if (anchor) path.unshift(anchor)
221 }
222
223 el = current.parentElement
224 }
225
226 return path
227}
228
229const getEnclosingTabPath = (el: HTMLElement) => {
230 const panel = el.closest<HTMLElement>(
231 '.plugin-tabs--content[data-tab-anchor]'
232 )
233 const tabs = panel?.closest<HTMLElement>('.plugin-tabs')
234 return tabs ? getTabPathForGroup(tabs) : []
235}
236
237const updateQueryForCollapsible = async (details: HTMLElement) => {
238 await nextTick()
239 await nextFrame()
240
241 const collapsiblePath = getOpenCollapsiblePath(details)
242 const tabPath = getEnclosingTabPath(details)
243
244 const nextUrl = buildUrl({
245 tabs: tabPath.length ? tabPath : undefined,
246 collapsibles: collapsiblePath
247 })
248 const currentUrl =
249 `${window.location.pathname}${window.location.search}${window.location.hash}`
250 if (nextUrl === currentUrl) return
251
252 window.history.pushState(null, '', nextUrl)
253 rewriteAnchorLinks()
254}
255
256const queueCollapsibleQueryUpdate = (target: EventTarget | null) => {
257 if (!(target instanceof HTMLElement)) return
258
259 const summary = target.closest<HTMLElement>('summary')
260 const details = summary?.parentElement
261 if (details instanceof HTMLElement && details.matches(COLLAPSIBLE_SELECTOR)) {
262 void updateQueryForCollapsible(details)
263 }
264}
265
266const selectCollapsiblesByPath = async (collapsiblePath: string[]) => {
267 let root: ParentNode = document
268 let opened: HTMLElement | undefined
269
270 for (const anchor of collapsiblePath) {
271 const details = root.querySelector<HTMLDetailsElement>(
272 `details[data-collapsible-anchor="${CSS.escape(anchor)}"]`
273 )
274 if (!details) return opened
275
276 opened = details
277 if (!details.open) {
278 details.open = true
279 await nextTick()
280 await nextFrame()
281 }
282
283 root = details
284 }
285
286 return opened
287}
288
289const TAB_LINK_MARKER = 'tab-'
290
291const rewriteAnchorLinks = () => {
292 const origin = window.location.origin
293 const pathname = window.location.pathname
294
295 document
296 .querySelectorAll<HTMLAnchorElement>('.VPDoc .vp-doc a[href]')
297 .forEach((link) => {
298 // Accept either the original `#…` form or a previously-rewritten absolute URL.
299 const raw = link.getAttribute('href') ?? ''
300 let fragment: string | null = null
301 if (raw.startsWith('#') && raw.length > 1) {
302 fragment = raw.slice(1)
303 } else if (raw.startsWith(origin + pathname + '#')) {
304 fragment = raw.slice((origin + pathname + '#').length)
305 } else if (raw.startsWith(origin + pathname + '?')) {
306 // Already rewritten as a tab link — re-derive the tab name and re-stamp.
307 const qs = raw.slice((origin + pathname + '?').length).split('#')[0]
308 const tabName = new URLSearchParams(qs).get(TAB_QUERY_PARAM)
309 if (tabName) {
310 const href = `${origin}${pathname}?${TAB_QUERY_PARAM}=${
311 encodeURIComponent(tabName)
312 }`
313 if (link.getAttribute('href') !== href) {
314 link.setAttribute('href', href)
315 }
316 }
317 return
318 } else {
319 return
320 }
321
322 const isTabLink = fragment.startsWith(TAB_LINK_MARKER)
323 const name = (isTabLink
324 ? fragment.slice(TAB_LINK_MARKER.length)
325 : fragment).trim()
326 if (!name) return
327
328 // Use absolute URLs so the browser's Copy Link has nothing to merge with
329 // the current ?tabs= query.
330 const href = isTabLink
331 ? `${origin}${pathname}?${TAB_QUERY_PARAM}=${encodeURIComponent(name)}`
332 : `${origin}${pathname}#${name}`
333
334 if (link.getAttribute('href') !== href) link.setAttribute('href', href)
335 })
336}
337
338const selectTabsByPath = async (tabPath: string[]) => {
339 let root: ParentNode = document
340 let selectedTabs: HTMLElement | undefined
341
342 for (const anchor of tabPath) {
343 const button = root.querySelector<HTMLButtonElement>(
344 `.plugin-tabs--tab[role="tab"][data-tab-anchor="${CSS.escape(anchor)}"]`
345 )
346 if (!button) return selectedTabs
347
348 const tabs = button.closest<HTMLElement>('.plugin-tabs')
349 if (!tabs) return selectedTabs
350
351 selectedTabs = tabs
352 if (button.getAttribute('aria-selected') !== 'true') {
353 button.click()
354 await nextTick()
355 await nextFrame()
356 }
357
358 root = getPanelForTabButton(button) ?? tabs
359 }
360
361 return selectedTabs
362}
363
364const selectLegacyTabHash = async (hash: string) => {
365 const button = document.querySelector<HTMLButtonElement>(
366 `.plugin-tabs--tab[role="tab"][data-tab-anchor="${CSS.escape(hash)}"]`
367 )
368 if (!button) return
369
370 if (button.getAttribute('aria-selected') !== 'true') {
371 button.click()
372 await nextTick()
373 await nextFrame()
374 }
375
376 const tabs = button.closest<HTMLElement>('.plugin-tabs')
377 if (tabs) {
378 window.history.replaceState(null, '', buildUrlWithTabs([hash]))
379 }
380 return tabs
381}
382
383const getSelectedTabScrollTarget = (tabs: HTMLElement) => {
384 const selectedTab = tabs.querySelector<HTMLButtonElement>(
385 '.plugin-tabs--tab[aria-selected="true"]'
386 )
387 return selectedTab ? getPanelForTabButton(selectedTab) ?? tabs : tabs
388}
389
390const scrollToElement = (target: HTMLElement, smooth = true) => {
391 requestAnimationFrame(() => {
392 requestAnimationFrame(() => {
393 const navBar = document.querySelector<HTMLElement>('.VPNavBar')
394 const navOffset = navBar ? navBar.offsetHeight : 0
395 window.scrollTo({
396 top: target.getBoundingClientRect().top + window.scrollY - navOffset,
397 behavior: smooth &&
398 !window.matchMedia('(prefers-reduced-motion: reduce)').matches
399 ? 'smooth'
400 : 'auto'
401 })
402 target.setAttribute('tabindex', '-1')
403 target.focus({ preventScroll: true })
404 })
405 })
406}
407
408const openCollapsibles = async (target: HTMLElement) => {
409 const activeTarget = target
410 let scrollTarget = getScrollTargetForAnchor(activeTarget)
411 let el: HTMLElement | null = activeTarget
412
413 while ((el = el.closest('details'))) {
414 el.open = true
415 scrollTarget = el
416 el = el.parentElement
417 }
418
419 const tagName = activeTarget.tagName
420 if (tagName.length === 2 && tagName[0] === 'H') {
421 const level = +tagName[1]
422 if (level >= 1 && level <= 6) {
423 const terms = getSearchTerms(searchQuery)
424 const detailsContainsTerms = (d: HTMLElement) => {
425 if (!terms.length) return false
426 const text = (d.textContent ?? '').toLowerCase()
427 return terms.every((term) => text.includes(term))
428 }
429
430 let sibling = activeTarget.nextElementSibling
431
432 while (sibling) {
433 const siblingTag = sibling.tagName
434 if (
435 siblingTag.length === 2 && siblingTag[0] === 'H' &&
436 +siblingTag[1] <= level
437 ) break
438
439 if (siblingTag === 'DETAILS') {
440 if (detailsContainsTerms(sibling as HTMLElement)) {
441 ;(sibling as HTMLDetailsElement).open = true
442 if (scrollTarget === activeTarget) {
443 scrollTarget = sibling as HTMLElement
444 }
445 }
446 }
447
448 const nested = sibling.getElementsByTagName('details')
449 for (let i = 0, len = nested.length; i < len; i++) {
450 if (detailsContainsTerms(nested[i])) {
451 nested[i].open = true
452 if (scrollTarget === activeTarget) scrollTarget = nested[i]
453 }
454 }
455
456 sibling = sibling.nextElementSibling
457 }
458 }
459 }
460
461 await nextTick()
462 await nextFrame()
463
464 scrollToElement(scrollTarget)
465}
466
467const resetSearchNavigation = () => {
468 searchNavigated = false
469 searchQuery = ''
470}
471
472const tryOpenAnchoredContent = async () => {
473 await nextTick()
474 await nextFrame()
475
476 const requestedTabs = getRequestedTabPath()
477 const selectedTabs = requestedTabs.length
478 ? await selectTabsByPath(requestedTabs)
479 : undefined
480 const requestedCollapsibles = getRequestedCollapsiblePath()
481 const openedCollapsible = requestedCollapsibles.length
482 ? await selectCollapsiblesByPath(requestedCollapsibles)
483 : undefined
484 const hash = window.location.hash.slice(1)
485
486 if (!hash) {
487 resetSearchNavigation()
488 if (openedCollapsible) {
489 scrollToElement(openedCollapsible, false)
490 } else if (selectedTabs) {
491 scrollToElement(getSelectedTabScrollTarget(selectedTabs), false)
492 }
493 return
494 }
495
496 let target = getTargetByHash(hash)
497
498 if (!target && !requestedTabs.length) {
499 const legacyTabs = await selectLegacyTabHash(hash)
500 if (legacyTabs) {
501 resetSearchNavigation()
502 scrollToElement(getSelectedTabScrollTarget(legacyTabs), false)
503 return
504 }
505 }
506
507 if (!target) {
508 if (searchNavigated) resetSearchNavigation()
509 return
510 }
511
512 if (searchNavigated) {
513 await openCollapsibles(target)
514 const collapsiblePath = getOpenCollapsiblePath(target)
515 if (collapsiblePath.length) {
516 const tabPath = getEnclosingTabPath(target)
517 window.history.replaceState(
518 null,
519 '',
520 buildUrl({
521 tabs: tabPath.length ? tabPath : undefined,
522 collapsibles: collapsiblePath
523 })
524 )
525 rewriteAnchorLinks()
526 }
527 resetSearchNavigation()
528 return
529 }
530
531 const isTabRelatedTarget = target.classList.contains('tab-search-heading') ||
532 Boolean(target.closest('.plugin-tabs'))
533
534 if (
535 !isTabRelatedTarget &&
536 new URLSearchParams(window.location.search).has(TAB_QUERY_PARAM)
537 ) {
538 window.history.replaceState(null, '', buildUrlWithTabs([], hash))
539 scrollToElement(getScrollTargetForAnchor(target), false)
540 return
541 }
542
543 if (target.classList.contains('tab-search-heading')) {
544 const tabs = target.closest<HTMLElement>('.plugin-tabs')
545 if (tabs) {
546 window.history.replaceState(
547 null,
548 '',
549 buildUrlWithTabs(getTabPathForGroup(tabs))
550 )
551 }
552 }
553
554 if (
555 selectedTabs ||
556 target.classList.contains('tab-search-heading')
557 ) {
558 scrollToElement(getScrollTargetForAnchor(target), false)
559 }
560}
561
562const rewriteAnchorLinksDeferred = () => nextTick(() => rewriteAnchorLinks())
563
564let outlineFollowObserver: MutationObserver | null = null
565let outlineFollowRaf = 0
566
567const syncMobileOutlineActive = () => {
568 const dropdownLinks = Array.from(
569 document.querySelectorAll<HTMLAnchorElement>(
570 '.VPLocalNavOutlineDropdown .outline a.outline-link'
571 )
572 )
573 if (!dropdownLinks.length) return
574
575 const scrollY = window.scrollY
576 const isBottom =
577 Math.abs(scrollY + window.innerHeight - document.body.offsetHeight) < 1
578
579 const entries = dropdownLinks
580 .map(link => {
581 const href = link.getAttribute('href') ?? ''
582 const id = href.startsWith('#') ? decodeURIComponent(href.slice(1)) : ''
583 const el = id ? document.getElementById(id) : null
584 return el ? { href, top: el.getBoundingClientRect().top + scrollY } : null
585 })
586 .filter((e): e is { href: string; top: number } => e !== null)
587 .sort((a, b) => a.top - b.top)
588
589 let activeHref: string | null = null
590 if (entries.length && scrollY >= 1) {
591 if (isBottom) {
592 activeHref = entries[entries.length - 1].href
593 } else {
594 for (const { href, top } of entries) {
595 if (top > scrollY + getScrollOffset() + 4) break
596 activeHref = href
597 }
598 }
599 }
600
601 dropdownLinks.forEach(link => {
602 link.classList.toggle('active', link.getAttribute('href') === activeHref)
603 })
604}
605
606let mobileOutlineScrollRaf = 0
607const onMobileOutlineScroll = () => {
608 cancelAnimationFrame(mobileOutlineScrollRaf)
609 mobileOutlineScrollRaf = requestAnimationFrame(syncMobileOutlineActive)
610}
611
612const followActiveOutlineLink = () => {
613 cancelAnimationFrame(outlineFollowRaf)
614
615 outlineFollowRaf = requestAnimationFrame(() => {
616 const activeLink = document.querySelector<HTMLElement>(
617 '.VPDocAsideOutline a.outline-link.active'
618 )
619 const scroller = activeLink?.closest<HTMLElement>('.aside-container')
620 if (!activeLink || !scroller) return
621
622 const linkRect = activeLink.getBoundingClientRect()
623 const scrollerRect = scroller.getBoundingClientRect()
624 const margin = 32
625
626 if (linkRect.top < scrollerRect.top + margin) {
627 scroller.scrollTop += linkRect.top - scrollerRect.top - margin
628 } else if (linkRect.bottom > scrollerRect.bottom - margin) {
629 scroller.scrollTop += linkRect.bottom - scrollerRect.bottom + margin
630 }
631 })
632}
633
634const setupOutlineFollow = () => {
635 outlineFollowObserver?.disconnect()
636 outlineFollowObserver = null
637
638 const outline = document.querySelector('.VPDocAsideOutline')
639 if (!outline) return
640
641 outlineFollowObserver = new MutationObserver((mutations) => {
642 if (
643 mutations.some((mutation) =>
644 mutation.type === 'childList' ||
645 (mutation.target instanceof HTMLElement &&
646 mutation.target.matches('a.outline-link'))
647 )
648 ) {
649 followActiveOutlineLink()
650 }
651 })
652
653 outlineFollowObserver.observe(outline, {
654 attributes: true,
655 attributeFilter: ['class'],
656 childList: true,
657 subtree: true
658 })
659 followActiveOutlineLink()
660}
661
662const BOOKMARK_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z"/></svg>`
663
664function syncTocBookmarkStates() {
665 const path = route.path
666 document.querySelectorAll<HTMLElement>('.toc-bookmark-btn').forEach(btn => {
667 const anchor = btn.dataset.anchor ?? ''
668 btn.classList.toggle('is-bookmarked', isBookmarked(anchor, path))
669 })
670}
671
672function addBookmarkBtnToLi(li: HTMLElement, path: string) {
673 if (li.querySelector('.toc-bookmark-btn')) return
674
675 const link = li.querySelector<HTMLAnchorElement>(':scope > .outline-link')
676 if (!link) return
677
678 const hrefAttr = link.getAttribute('href') ?? ''
679 const anchor = hrefAttr.startsWith('#') ? hrefAttr.slice(1) : hrefAttr
680 const title = link.textContent?.trim() ?? ''
681 if (!anchor || !title) return
682
683 const btn = document.createElement('button')
684 btn.className = 'toc-bookmark-btn'
685 btn.setAttribute('aria-label', `Bookmark "${title}"`)
686 btn.dataset.anchor = anchor
687 btn.innerHTML = BOOKMARK_SVG
688
689 if (isBookmarked(anchor, path)) btn.classList.add('is-bookmarked')
690
691 btn.addEventListener('click', (e) => {
692 e.preventDefault()
693 e.stopPropagation()
694 bookmarkToggle({ anchor, title, path })
695 btn.classList.toggle('is-bookmarked', isBookmarked(anchor, path))
696 })
697
698 link.appendChild(btn)
699}
700
701let tocMutationObserver: MutationObserver | null = null
702let tocRaf = 0
703
704function scanTocItems(path: string) {
705 // Desktop sidebar — VPDocOutlineItem is called with :root="true"
706 document.querySelectorAll<HTMLElement>('.VPDocOutlineItem.root > li').forEach(li => addBookmarkBtnToLi(li, path))
707 // Mobile dropdown — VPDocOutlineItem is called without root prop, so the ul gets class "nested"
708 document.querySelectorAll<HTMLElement>('.VPLocalNavOutlineDropdown .outline > .VPDocOutlineItem > li').forEach(li => addBookmarkBtnToLi(li, path))
709}
710
711function setupTocBookmarks() {
712 const path = route.path
713 document.querySelectorAll<HTMLElement>('.toc-bookmark-btn').forEach(btn => btn.remove())
714 scanTocItems(path)
715
716 // Mobile dropdown items are v-if rendered on open — watch for them being added
717 tocMutationObserver?.disconnect()
718 tocMutationObserver = new MutationObserver(() => {
719 cancelAnimationFrame(tocRaf)
720 tocRaf = requestAnimationFrame(() => {
721 scanTocItems(route.path)
722 syncMobileOutlineActive()
723 })
724 })
725 tocMutationObserver.observe(document.body, { childList: true, subtree: true })
726}
727
728onMounted(tryOpenAnchoredContent)
729onMounted(rewriteAnchorLinksDeferred)
730onMounted(() => nextTick(setupOutlineFollow))
731onMounted(() => nextTick(setupTocBookmarks))
732onMounted(() => window.addEventListener('scroll', onMobileOutlineScroll, { passive: true }))
733onUnmounted(() => window.removeEventListener('scroll', onMobileOutlineScroll))
734watch(() => route.data, () => {
735 void tryOpenAnchoredContent()
736 rewriteAnchorLinksDeferred()
737 nextTick(setupOutlineFollow)
738 nextTick(setupManualCopyButtons)
739 nextTick(setupTocBookmarks)
740}, { flush: 'post' })
741watch(() => route.query, () => {
742 void tryOpenAnchoredContent()
743 rewriteAnchorLinksDeferred()
744}, { flush: 'post' })
745watch(() => route.hash, tryOpenAnchoredContent, { flush: 'post' })
746
747function onSidebarEnter() {
748 sidebarRef.value?.focus()
749}
750
751interface BreadcrumbItem {
752 text: string
753 link?: string
754}
755
756const buildBreadcrumbs = (
757 items: Theme.SidebarItem[],
758 currentPath: string
759): BreadcrumbItem[] => {
760 for (const item of items) {
761 // Check if this item matches the current path
762 if (item.link === currentPath) {
763 return [
764 {
765 text: item.text!.replace('mr-2 block w-4 h-4 bg-cover', '').trim(),
766 link: item.link
767 }
768 ]
769 }
770
771 // Check nested items
772 if (item.items) {
773 const nestedBreadcrumbs = buildBreadcrumbs(item.items, currentPath)
774 if (nestedBreadcrumbs.length > 0) {
775 return [
776 {
777 text: item.text!.replace('mr-2 block w-4 h-4 bg-cover', '').trim(),
778 link: item.link
779 },
780 ...nestedBreadcrumbs
781 ]
782 }
783 }
784 }
785 return []
786}
787
788const breadcrumbs = computed(() => {
789 const currentPath = route.path
790 // @ts-expect-error
791 return buildBreadcrumbs(sidebar, currentPath)
792})
793
794const { effectsEnabled } = useEffects()
795
796watchEffect(() => {
797 if (import.meta.env.SSR) return
798
799 // Effects are off by default; the class strips blur/transitions/scaling.
800 document.documentElement.classList.toggle(
801 'effects-disabled',
802 !effectsEnabled.value
803 )
804})
805
806type ShadeMap = Record<string, string>
807type PaletteEntry = ShadeMap | { dark: ShadeMap; light: ShadeMap }
808
809const accentPalettes: Record<string, PaletteEntry> = {
810 ayanami: {
811 400: 'oklch(0.722 0.105 247.48)',
812 500: 'oklch(0.626 0.098 247.46)',
813 600: 'oklch(0.523 0.081 246.86)',
814 700: 'oklch(0.43 0.066 246.75)',
815 800: 'oklch(0.335 0.052 246.76)',
816 },
817 asuka: {
818 400: 'oklch(0.740 0.210 32)',
819 500: 'oklch(0.650 0.240 30)',
820 600: 'oklch(0.555 0.238 28)',
821 700: 'oklch(0.455 0.205 26)',
822 800: 'oklch(0.370 0.165 24)',
823 },
824 irys: {
825 400: 'oklch(0.716 0.188 5.18)',
826 500: 'oklch(0.659 0.237 8.99)',
827 600: 'oklch(0.584 0.229 10.32)',
828 700: 'oklch(0.538 0.213 9.67)',
829 800: 'oklch(0.475 0.187 5.94)',
830 },
831 inanis: {
832 400: 'oklch(0.762 0.073 302.02)',
833 500: 'oklch(0.663 0.102 301.22)',
834 600: 'oklch(0.580 0.119 301.34)',
835 700: 'oklch(0.508 0.114 301.00)',
836 800: 'oklch(0.452 0.094 302.20)',
837 },
838 baelz: {
839 400: 'oklch(0.720 0.215 22.00)',
840 500: 'oklch(0.640 0.255 22.00)',
841 600: 'oklch(0.555 0.268 22.00)',
842 700: 'oklch(0.472 0.248 22.00)',
843 800: 'oklch(0.395 0.208 22.00)',
844 },
845 amelia: {
846 400: 'oklch(0.800 0.085 75.49)',
847 500: 'oklch(0.710 0.090 72.47)',
848 600: 'oklch(0.594 0.085 69.07)',
849 700: 'oklch(0.496 0.078 72.12)',
850 800: 'oklch(0.391 0.062 68.86)',
851 },
852 suisei: {
853 400: 'oklch(0.827 0.096 224.60)',
854 500: 'oklch(0.740 0.119 230.91)',
855 600: 'oklch(0.645 0.127 236.29)',
856 700: 'oklch(0.548 0.120 241.26)',
857 800: 'oklch(0.451 0.106 244.63)',
858 },
859 miku: {
860 400: 'oklch(0.788 0.133 184.43)',
861 500: 'oklch(0.711 0.123 185.28)',
862 600: 'oklch(0.607 0.104 187.31)',
863 700: 'oklch(0.515 0.086 189.60)',
864 800: 'oklch(0.441 0.071 190.95)',
865 },
866 fubuki: {
867 dark: {
868 400: 'oklch(0.88 0 0)',
869 500: 'oklch(0.78 0 0)',
870 600: 'oklch(0.68 0 0)',
871 700: 'oklch(0.58 0 0)',
872 800: 'oklch(0.48 0 0)',
873 },
874 light: {
875 400: 'oklch(0.52 0 0)',
876 500: 'oklch(0.42 0 0)',
877 600: 'oklch(0.32 0 0)',
878 700: 'oklch(0.22 0 0)',
879 800: 'oklch(0.12 0 0)',
880 },
881 },
882}
883
884const accentColor = useStorage(AccentColorStorageKey, 'ayanami')
885const accentBg = useStorage(AccentBgStorageKey, false)
886const accentBgStrength = useStorage(AccentBgStrengthStorageKey, 60)
887
888// Accent-tinted replacements for the neutral tokens in style.scss.
889// Lightness matches the original hex values, so contrast is unchanged.
890// Entries are [lightness, chroma] or [lightness, chroma, alpha].
891type TintEntry = [number, number] | [number, number, number]
892const accentBgTokens: Record<'dark' | 'light', Record<string, TintEntry>> = {
893 dark: {
894 '--vp-c-bg': [0.187, 0.024],
895 '--vp-c-bg-alt': [0.164, 0.022],
896 '--vp-c-bg-elv': [0.224, 0.028],
897 '--vp-c-bg-soft': [0.224, 0.028],
898 '--vp-c-divider': [0.26, 0.032],
899 '--vp-c-border': [0.57, 0.02],
900 '--vp-c-text-1': [0.915, 0.012],
901 '--vp-c-text-2': [0.742, 0.012],
902 '--vp-c-text-3': [0.655, 0.012],
903 '--wk-c-menu-bg': [0.295, 0.032],
904 '--wk-c-nav-solid-bg': [0.2, 0.024],
905 '--nav-pill-bg': [0.205, 0.024, 0.7],
906 '--wk-fs-header-divider': [0.44, 0.02, 0.65],
907 },
908 light: {
909 '--vp-c-bg': [0.986, 0.012],
910 '--vp-c-bg-alt': [0.958, 0.024],
911 '--vp-c-bg-elv': [0.958, 0.024],
912 '--vp-c-bg-soft': [0.958, 0.024],
913 '--vp-c-divider': [0.828, 0.036],
914 '--vp-c-border': [0.815, 0.024],
915 '--vp-c-gutter': [0.913, 0.02],
916 '--vp-c-text-1': [0.224, 0.016],
917 '--vp-c-text-2': [0.309, 0.014],
918 '--vp-c-text-3': [0.396, 0.014],
919 '--wk-c-menu-bg': [0.928, 0.026],
920 '--wk-c-nav-solid-bg': [0.986, 0.012],
921 '--nav-pill-bg': [0.99, 0.01, 0.8],
922 '--wk-fs-header-divider': [0.715, 0.02, 0.25],
923 },
924}
925const accentBgTokenKeys = [...new Set([
926 ...Object.keys(accentBgTokens.dark),
927 ...Object.keys(accentBgTokens.light),
928])]
929
930const applyAccentTheme = () => {
931 if (import.meta.env.SSR) return
932 const palette = accentPalettes[accentColor.value] ?? accentPalettes.ayanami
933 const shades = 'dark' in palette
934 ? (isDark.value ? palette.dark : palette.light)
935 : palette
936 const el = document.documentElement
937 if (isDark.value) {
938 el.style.setProperty('--vp-c-brand-1', shades['400'])
939 el.style.setProperty('--vp-c-brand-2', shades['500'])
940 el.style.setProperty('--vp-c-brand-3', shades['700'])
941 el.style.setProperty('--vp-c-brand-soft', `color-mix(in srgb, ${shades['500']} 20%, transparent)`)
942 el.style.setProperty('--vp-c-sidebar-active', `color-mix(in srgb, ${shades['500']} 15%, transparent)`)
943 } else {
944 el.style.setProperty('--vp-c-brand-1', shades['500'])
945 el.style.setProperty('--vp-c-brand-2', shades['600'])
946 el.style.setProperty('--vp-c-brand-3', shades['800'])
947 el.style.setProperty('--vp-c-brand-soft', `color-mix(in srgb, ${shades['400']} 40%, transparent)`)
948 el.style.setProperty('--vp-c-sidebar-active', `color-mix(in srgb, ${shades['800']} 15%, transparent)`)
949 }
950
951 for (const key of accentBgTokenKeys) el.style.removeProperty(key)
952 const userStrength = accentBg.value
953 ? Math.min(100, Math.max(0, Number(accentBgStrength.value) || 0)) / 100
954 : 0
955 if (userStrength > 0) {
956 const parsed = shades['500'].match(/oklch\(\s*[\d.]+\s+([\d.]+)\s+([\d.]+)/)
957 if (parsed) {
958 // Tint scales with the accent's own chroma (full tint at C >= 0.10,
959 // grayscale accents stay gray), then with the intensity preset.
960 const strength = Math.min(1, Number(parsed[1]) / 0.10) * userStrength * 1.5
961 const hue = parsed[2]
962 const tokens = accentBgTokens[isDark.value ? 'dark' : 'light']
963 for (const [key, [l, c, alpha]] of Object.entries(tokens)) {
964 const chroma = (c * strength).toFixed(4)
965 const suffix = alpha === undefined ? '' : ` / ${alpha}`
966 el.style.setProperty(key, `oklch(${l} ${chroma} ${hue}${suffix})`)
967 }
968 }
969 }
970}
971
972// Applying the tint restyles the whole page, so throttle rapid changes
973// (leading + trailing: single clicks apply instantly, the last value sticks).
974const applyAccentThemeThrottled = useThrottleFn(applyAccentTheme, 100, true)
975
976watch(
977 [accentColor, isDark, accentBg, accentBgStrength],
978 () => applyAccentThemeThrottled(),
979 { immediate: true }
980)
981
982function initTitleOnly() {
983 document.querySelectorAll('.custom-block').forEach(block => {
984 const children = [...block.children]
985 const hasOnlyTitle = children.every(el =>
986 el.classList.contains('custom-block-title')
987 )
988 if (hasOnlyTitle) block.classList.add('title-only')
989 })
990}
991
992function initCopyButtonsInRoot(root: ParentNode) {
993 root.querySelectorAll<HTMLTableElement>('table').forEach(table => {
994 const headers = table.querySelectorAll<HTMLTableCellElement>('thead th')
995 let manualColIndex = -1
996 headers.forEach((th, i) => {
997 if (th.textContent?.trim() === 'Manual') manualColIndex = i
998 })
999 if (manualColIndex === -1) return
1000
1001 // Track how many more rows each column is occupied by a rowspan from above
1002 const colOccupied: number[] = []
1003
1004 table.querySelectorAll<HTMLTableRowElement>('tbody tr').forEach(row => {
1005 const cells = Array.from(row.querySelectorAll('td'))
1006 let cellIdx = 0
1007 let col = 0
1008 let manualCell: HTMLTableCellElement | null = null
1009
1010 while (col <= manualColIndex) {
1011 // Column occupied by a rowspan from a previous row — skip it
1012 if ((colOccupied[col] ?? 0) > 0) {
1013 colOccupied[col]--
1014 col++
1015 continue
1016 }
1017
1018 if (cellIdx >= cells.length) break
1019 const cell = cells[cellIdx++]
1020 const colspan = cell.colSpan || 1
1021 const rowspan = cell.rowSpan || 1
1022
1023 // Register future occupation for rowspan > 1
1024 if (rowspan > 1) {
1025 for (let c = col; c < col + colspan; c++) {
1026 colOccupied[c] = (colOccupied[c] ?? 0) + (rowspan - 1)
1027 }
1028 }
1029
1030 if (col <= manualColIndex && col + colspan > manualColIndex) {
1031 manualCell = cell
1032 }
1033
1034 col += colspan
1035 }
1036
1037 if (!manualCell || manualCell.querySelector('.manual-copy-btn')) return
1038
1039 const link = manualCell.querySelector<HTMLAnchorElement>('a[href]')
1040 if (!link) return
1041 const url = link.getAttribute('href')!
1042
1043 const btn = document.createElement('button')
1044 btn.className = 'manual-copy-btn'
1045 btn.title = 'Copy URL'
1046 const icon = document.createElement('span')
1047 icon.className = 'i-lucide:copy'
1048 btn.appendChild(icon)
1049
1050 btn.addEventListener('click', async (e) => {
1051 e.preventDefault()
1052 try {
1053 await navigator.clipboard.writeText(url)
1054 icon.className = 'i-lucide:check'
1055 btn.classList.add('copied')
1056 setTimeout(() => {
1057 icon.className = 'i-lucide:copy'
1058 btn.classList.remove('copied')
1059 }, 2000)
1060 } catch {}
1061 })
1062
1063 manualCell.classList.add('has-manual-copy')
1064 manualCell.appendChild(btn)
1065 })
1066 })
1067}
1068
1069let copyButtonObserver: MutationObserver | null = null
1070
1071function setupManualCopyButtons() {
1072 initCopyButtonsInRoot(document)
1073
1074 copyButtonObserver?.disconnect()
1075 copyButtonObserver = new MutationObserver((mutations) => {
1076 for (const mutation of mutations) {
1077 for (const node of mutation.addedNodes) {
1078 if (!(node instanceof HTMLElement)) continue
1079 if (node.classList.contains('plugin-tabs--content')) {
1080 initCopyButtonsInRoot(node)
1081 } else {
1082 node.querySelectorAll<HTMLElement>('.plugin-tabs--content').forEach(
1083 panel => initCopyButtonsInRoot(panel)
1084 )
1085 }
1086 }
1087 }
1088 })
1089 copyButtonObserver.observe(document.body, { childList: true, subtree: true })
1090}
1091
1092watch(
1093 () => route.path,
1094 () => nextTick(() => { initTitleOnly(); setupManualCopyButtons() }),
1095 { flush: 'post' }
1096)
1097
1098onMounted(() => {
1099 if (import.meta.env.SSR) return
1100
1101 window.addEventListener(BOOKMARK_CHANGE_EVENT, syncTocBookmarkStates)
1102
1103 initTitleOnly()
1104 nextTick(setupManualCopyButtons)
1105
1106 // Icon tooltip: fixed-position popup appended to <body> to escape table overflow clipping
1107 const tooltipEl = document.createElement('div')
1108 tooltipEl.className = 'icon-tip-popup'
1109 document.body.appendChild(tooltipEl)
1110
1111 const showTooltip = (e: MouseEvent) => {
1112 const target = (e.target as HTMLElement).closest('.icon-tip') as
1113 | HTMLElement
1114 | null
1115 if (!target) return
1116 const tip = target.dataset.tip
1117 if (!tip) return
1118
1119 tooltipEl.textContent = tip
1120 tooltipEl.classList.add('visible')
1121
1122 const rect = target.getBoundingClientRect()
1123 const tipWidth = tooltipEl.offsetWidth
1124 const tipHeight = tooltipEl.offsetHeight
1125 let left = rect.left + rect.width / 2 - tipWidth / 2
1126 left = Math.max(8, Math.min(left, window.innerWidth - tipWidth - 8))
1127 const top = rect.top - tipHeight - 6
1128
1129 tooltipEl.style.left = `${left}px`
1130 tooltipEl.style.top = `${top}px`
1131 }
1132
1133 const hideTooltip = () => {
1134 tooltipEl.classList.remove('visible')
1135 }
1136
1137 document.addEventListener('mouseover', showTooltip)
1138 document.addEventListener('mouseout', hideTooltip)
1139 document.addEventListener('scroll', hideTooltip, true)
1140
1141 const onCaptureClick = (e: MouseEvent) => {
1142 if (!e.isTrusted) return
1143 const link = (e.target as HTMLElement).closest<HTMLAnchorElement>('a[href]')
1144 if (!link) return
1145 const raw = link.getAttribute('href') ?? ''
1146
1147 // ── Tab link: #tab-name or already-rewritten /path?tabs=name ──────────
1148 const tabFromHash = raw.startsWith('#' + TAB_LINK_MARKER)
1149 ? raw.slice(1 + TAB_LINK_MARKER.length)
1150 : null
1151 let tabFromQuery: string | null = null
1152 if (
1153 !e.defaultPrevented &&
1154 !tabFromHash &&
1155 raw.includes(`?${TAB_QUERY_PARAM}=`) &&
1156 !raw.includes('#')
1157 ) {
1158 try {
1159 const url = new URL(raw, window.location.href)
1160 const samePage = url.origin === window.location.origin &&
1161 url.pathname === window.location.pathname
1162 tabFromQuery = samePage
1163 ? url.searchParams.get(TAB_QUERY_PARAM)
1164 : null
1165 } catch {
1166 tabFromQuery = null
1167 }
1168 }
1169 const tabName = tabFromHash ?? tabFromQuery
1170
1171 if (tabName) {
1172 e.preventDefault()
1173 e.stopImmediatePropagation()
1174 window.history.pushState(null, '', buildUrlWithTabs([tabName]))
1175 rewriteAnchorLinks()
1176 void (async () => {
1177 const tabs = await selectTabsByPath([tabName])
1178 if (tabs) scrollToElement(getSelectedTabScrollTarget(tabs), false)
1179 })()
1180 return
1181 }
1182
1183 // ── Plain heading link: #name or already-rewritten /path#name ─────────
1184 // Only intercept when ?tabs= is present — otherwise let the router handle normally.
1185 if (!new URLSearchParams(window.location.search).has(TAB_QUERY_PARAM)) {
1186 return
1187 }
1188
1189 let hash: string | null = null
1190 if (raw.startsWith('#') && raw.length > 1) {
1191 hash = raw.slice(1)
1192 } else if (raw.startsWith(window.location.pathname + '#')) {
1193 hash = raw.slice(window.location.pathname.length + 1)
1194 }
1195 if (!hash) return
1196
1197 e.preventDefault()
1198 e.stopImmediatePropagation()
1199 window.history.pushState(null, '', `${window.location.pathname}#${hash}`)
1200 rewriteAnchorLinks()
1201 void tryOpenAnchoredContent()
1202 }
1203
1204 document.addEventListener('click', onCaptureClick, { capture: true })
1205
1206 useEventListener(document, 'click', (e: MouseEvent) => {
1207 if (!e.isTrusted) return
1208 queueTabQueryUpdateForSelection(e.target)
1209 queueCollapsibleQueryUpdate(e.target)
1210 })
1211
1212 useEventListener(document, 'keydown', (e: KeyboardEvent) => {
1213 if (!e.isTrusted || (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight')) {
1214 return
1215 }
1216
1217 queueTabQueryUpdateForSelection(e.target)
1218 })
1219
1220 onUnmounted(() => {
1221 document.removeEventListener('click', onCaptureClick, { capture: true })
1222 document.removeEventListener('mouseover', showTooltip)
1223 document.removeEventListener('mouseout', hideTooltip)
1224 document.removeEventListener('scroll', hideTooltip, true)
1225 tooltipEl.remove()
1226 })
1227
1228 // Arrow key scrolling + Escape close for sidebars and content
1229 let activeScrollTarget: HTMLElement | Window = window
1230
1231 useEventListener(document, 'pointerdown', (e: PointerEvent) => {
1232 const el = e.target as HTMLElement
1233 if (homeSidebarOpen.value && sidebarRef.value?.contains(el)) {
1234 activeScrollTarget = sidebarRef.value
1235 } else if (el.closest('.VPSidebar')) {
1236 activeScrollTarget = el.closest('.VPSidebar') as HTMLElement
1237 } else {
1238 activeScrollTarget = window
1239 }
1240 })
1241
1242 const pxPerFrame = 18
1243 let scrollDirection = 0
1244 let scrollRaf = 0
1245
1246 function tickScroll() {
1247 if (!scrollDirection) return
1248 activeScrollTarget.scrollBy({ top: scrollDirection * pxPerFrame })
1249 scrollRaf = requestAnimationFrame(tickScroll)
1250 }
1251
1252 function stopScroll() {
1253 scrollDirection = 0
1254 cancelAnimationFrame(scrollRaf)
1255 }
1256
1257 useEventListener(document, 'keydown', (e: KeyboardEvent) => {
1258 if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp' && e.key !== 'Escape') {
1259 return
1260 }
1261
1262 if (e.key === 'Escape') {
1263 if (homeSidebarOpen.value) homeSidebarOpen.value = false
1264 return
1265 }
1266
1267 e.preventDefault()
1268 const dir = e.key === 'ArrowDown' ? 1 : -1
1269 if (scrollDirection === dir) return
1270 scrollDirection = dir
1271 cancelAnimationFrame(scrollRaf)
1272 scrollRaf = requestAnimationFrame(tickScroll)
1273 })
1274
1275 useEventListener(document, 'keyup', (e: KeyboardEvent) => {
1276 if (e.key === 'ArrowDown' || e.key === 'ArrowUp') stopScroll()
1277 })
1278
1279 onUnmounted(stopScroll)
1280
1281 // Close home NavScreen on outside click
1282 useEventListener(document, 'click', (e: Event) => {
1283 if (!isHome.value) return
1284 const screen = document.getElementById('VPNavScreen')
1285 if (!screen) return
1286 const hamburger = document.querySelector('.VPNavBarHamburger')
1287 if (
1288 screen.contains(e.target as Node) || hamburger?.contains(e.target as Node)
1289 ) return
1290 requestAnimationFrame(() => (hamburger as HTMLElement)?.click())
1291 })
1292})
1293
1294onUnmounted(() => {
1295 outlineFollowObserver?.disconnect()
1296 copyButtonObserver?.disconnect()
1297 tocMutationObserver?.disconnect()
1298 cancelAnimationFrame(outlineFollowRaf)
1299 cancelAnimationFrame(tocRaf)
1300 window.removeEventListener(BOOKMARK_CHANGE_EVENT, syncTocBookmarkStates)
1301})
1302</script>
1303
1304<template>
1305 <Layout>
1306 <template #layout-top>
1307 <!-- Home sidebar menu -->
1308 <template v-if="isHome">
1309 <Transition name="home-fade">
1310 <div
1311 v-if="homeSidebarOpen"
1312 class="home-sidebar-backdrop"
1313 @click="homeSidebarOpen = false"
1314 />
1315 </Transition>
1316 <Transition name="home-slide" @after-enter="onSidebarEnter">
1317 <aside
1318 v-if="homeSidebarOpen"
1319 ref="sidebarRef"
1320 class="home-sidebar"
1321 tabindex="-1"
1322 @click.stop
1323 >
1324 <div class="home-sidebar-header">
1325 <a href="/" class="home-sidebar-logo">
1326 <img
1327 v-if="logoSrc"
1328 :src="logoSrc"
1329 class="home-sidebar-logo-img"
1330 alt="Logo"
1331 />
1332 <span>{{ theme.siteTitle ?? site.title }}</span>
1333 </a>
1334 </div>
1335 <nav id="VPSidebarNav" class="home-sidebar-nav">
1336 <VPSidebarGroup :items="homeSidebarGroups" />
1337 <SidebarCard />
1338 </nav>
1339 </aside>
1340 </Transition>
1341 </template>
1342 </template>
1343 <template #doc-before>
1344 <!-- Breadcrumb Navigation -->
1345 <nav
1346 v-if="breadcrumbs.length > 0"
1347 class="breadcrumb mb-6 text-sm text-text-2"
1348 aria-label="Breadcrumb"
1349 >
1350 <ol class="flex flex-wrap items-center gap-2">
1351 <li>
1352 <a href="/" class="hover:text-primary transition-colors">
1353 <span class="i-lucide:home"></span>
1354 </a>
1355 </li>
1356 <li
1357 v-for="(crumb, index) in breadcrumbs"
1358 :key="crumb.link || index"
1359 class="flex items-center gap-2"
1360 >
1361 <span
1362 class="i-lucide:chevron-right text-text-3 flex-shrink-0"
1363 ></span>
1364 <span
1365 v-if="index === breadcrumbs.length - 1"
1366 v-html="crumb.text"
1367 class="font-medium text-text-1 break-words"
1368 ></span>
1369 <a
1370 v-else
1371 :href="crumb.link"
1372 v-html="crumb.text"
1373 class="hover:text-primary transition-colors break-words"
1374 ></a>
1375 </li>
1376 </ol>
1377 </nav>
1378 </template>
1379 <template #not-found>
1380 <NotFoundComponent />
1381 </template>
1382 <template #sidebar-nav-after>
1383 <SidebarCard />
1384 </template>
1385 <template #home-hero-info-before>
1386 <AnnouncementPill />
1387 </template>
1388 <template #nav-bar-content-after>
1389 <NavActions />
1390 </template>
1391 <template #nav-screen-content-before>
1392 <nav v-if="isHome" id="VPSidebarNavMobile" class="home-screen-nav">
1393 <VPSidebarGroup :items="homeSidebarGroups" />
1394 </nav>
1395 </template>
1396 <template #nav-screen-content-after>
1397 <NolebaseEnhancedReadabilitiesScreenMenu />
1398 </template>
1399 <template #layout-bottom>
1400 <SiteFooter />
1401 </template>
1402
1403 <template #nav-bar-title-before>
1404 <span
1405 v-if="isHome"
1406 class="home-menu-btn"
1407 role="button"
1408 tabindex="0"
1409 aria-label="Menu"
1410 @click.prevent.stop="homeSidebarOpen = !homeSidebarOpen"
1411 @keydown.enter.prevent.stop="homeSidebarOpen = !homeSidebarOpen"
1412 >
1413 <span class="vpi-align-left home-menu-icon" />
1414 </span>
1415 </template>
1416 </Layout>
1417</template>