Commit ddb2b92275

ddb2b9227536528c1f6db69c24ad7cf381ec2cec

parent: 9e030629ae

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-07-28 06:59 UTC

init

Layout: unified · split

docs/.vitepress/theme/Layout.vue +142 −2
@@ -36,6 +36,7 @@ import SidebarCard from './components/SidebarCard.vue'
36import { AccentBgStorageKey, AccentBgStrengthStorageKey, AccentColorStorageKey } from './constants' 36import { AccentBgStorageKey, AccentBgStrengthStorageKey, AccentColorStorageKey } from './constants'
37import { useEffects } from './composables/useEffects' 37import { useEffects } from './composables/useEffects'
38import { applyFavicons, removeFavicons, useFavicons } from './composables/useFavicons' 38import { applyFavicons, removeFavicons, useFavicons } from './composables/useFavicons'
39import { searchResultHighlightMode } from './searchState'
39 40
40const route = useRoute() 41const route = useRoute()
41const { frontmatter, isDark, site, theme } = useData() 42const { frontmatter, isDark, site, theme } = useData()
@@ -59,6 +60,7 @@ watch(() => route.path, () => {
59 60
60let searchNavigated = false 61let searchNavigated = false
61let searchQuery = '' 62let searchQuery = ''
63let searchResultText = ''
62 64
63if (!import.meta.env.SSR) { 65if (!import.meta.env.SSR) {
64 useEventListener(window, 'search-nav', (event) => { 66 useEventListener(window, 'search-nav', (event) => {
@@ -67,6 +69,10 @@ if (!import.meta.env.SSR) {
67 typeof event.detail?.query === 'string' 69 typeof event.detail?.query === 'string'
68 ? event.detail.query 70 ? event.detail.query
69 : '' 71 : ''
72 searchResultText = event instanceof CustomEvent &&
73 typeof event.detail?.resultText === 'string'
74 ? event.detail.resultText
75 : ''
70 }) 76 })
71} 77}
72 78
@@ -80,6 +86,127 @@ const getSearchTerms = (query: string) =>
80 .map((term) => term.trim()) 86 .map((term) => term.trim())
81 .filter(Boolean) 87 .filter(Boolean)
82 88
89const getSearchResultText = (value: string) => {
90 const el = document.createElement('div')
91 el.innerHTML = value
92 return (el.textContent ?? '').replace(/\s+/g, ' ').trim()
93}
94
95const removeSearchResultHighlights = () => {
96 document.querySelectorAll<HTMLElement>('.search-result-highlight').forEach(
97 (highlight) => highlight.replaceWith(...highlight.childNodes)
98 )
99}
100
101
102let highlightTerm = ''
103let highlightTabPath: string[] | null = null
104
105const isHighlightEnabled = () => {
106 const mode = searchResultHighlightMode.value
107 return mode !== 'off' && mode !== false
108}
109
110const isWordChar = (ch: string | undefined) =>
111 ch !== undefined && /[\p{L}\p{N}_]/u.test(ch)
112
113const getPanelTabPath = (panel: HTMLElement): string[] => {
114 const path: string[] = []
115 let current: HTMLElement | null = panel
116
117 while (current?.dataset.tabAnchor) {
118 path.unshift(current.dataset.tabAnchor)
119 const tabsGroup = current.closest<HTMLElement>('.plugin-tabs')
120 current = tabsGroup?.parentElement?.closest<HTMLElement>(
121 '.plugin-tabs--content[data-tab-anchor]'
122 ) ?? null
123 }
124
125 return path
126}
127
128const applyHighlightWithin = (root: HTMLElement, term: string) => {
129 const mode = searchResultHighlightMode.value
130 const termLower = term.toLocaleLowerCase()
131 const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
132 acceptNode(node) {
133 const parent = node.parentElement
134 if (!parent || parent.closest('.search-result-highlight, script, style')) {
135 return NodeFilter.FILTER_REJECT
136 }
137 return NodeFilter.FILTER_ACCEPT
138 }
139 })
140
141 let node: Text | null
142 while ((node = walker.nextNode() as Text | null)) {
143 const dataLower = node.data.toLocaleLowerCase()
144 let searchFrom = 0
145
146 while (true) {
147 const index = dataLower.indexOf(termLower, searchFrom)
148 if (index < 0) break
149
150 // Reject partial-word matches, e.g. "AnimeX" inside "AnimeXin" —
151 // only accept the term at an actual word boundary on both sides.
152 if (
153 isWordChar(node.data[index - 1]) ||
154 isWordChar(node.data[index + term.length])
155 ) {
156 searchFrom = index + 1
157 continue
158 }
159
160 const highlight = document.createElement('span')
161 highlight.className = 'search-result-highlight'
162 if (mode === 'solid') {
163 highlight.classList.add('search-result-highlight--solid')
164 }
165 const before = node.data.slice(0, index)
166 const match = node.data.slice(index, index + term.length)
167 const after = node.data.slice(index + term.length)
168 const fragment = document.createDocumentFragment()
169 if (before) fragment.append(before)
170 highlight.textContent = match
171 fragment.append(highlight)
172 if (after) fragment.append(after)
173 node.replaceWith(fragment)
174 return true
175 }
176 }
177 return false
178}
179
180const highlightSearchResult = (target?: HTMLElement) => {
181 removeSearchResultHighlights()
182 highlightTerm = ''
183 highlightTabPath = null
184
185 if (!isHighlightEnabled()) return
186
187 const term = getSearchResultText(searchResultText)
188 if (!target || !term) return
189
190 const panel = target.closest<HTMLElement>(
191 '.plugin-tabs--content[data-tab-anchor]'
192 )
193 highlightTabPath = panel ? getPanelTabPath(panel) : null
194 highlightTerm = term
195 applyHighlightWithin(target, term)
196}
197
198const reapplyHighlightIfNeeded = (panel: HTMLElement) => {
199 if (!highlightTerm || !highlightTabPath || !isHighlightEnabled()) return
200
201 const panelPath = getPanelTabPath(panel)
202 const isSamePanel = panelPath.length === highlightTabPath.length &&
203 panelPath.every((anchor, i) => anchor === highlightTabPath![i])
204 if (!isSamePanel) return
205
206 if (panel.querySelector('.search-result-highlight')) return
207 applyHighlightWithin(panel, highlightTerm)
208}
209
83const getTargetByHash = (hash: string) => { 210const getTargetByHash = (hash: string) => {
84 const ids = [hash] 211 const ids = [hash]
85 try { 212 try {
@@ -468,6 +595,7 @@ const openCollapsibles = async (target: HTMLElement) => {
468const resetSearchNavigation = () => { 595const resetSearchNavigation = () => {
469 searchNavigated = false 596 searchNavigated = false
470 searchQuery = '' 597 searchQuery = ''
598 searchResultText = ''
471} 599}
472 600
473const tryOpenAnchoredContent = async () => { 601const tryOpenAnchoredContent = async () => {
@@ -485,6 +613,11 @@ const tryOpenAnchoredContent = async () => {
485 const hash = window.location.hash.slice(1) 613 const hash = window.location.hash.slice(1)
486 614
487 if (!hash) { 615 if (!hash) {
616 const scrollTarget = openedCollapsible ??
617 (selectedTabs
618 ? getSelectedTabScrollTarget(selectedTabs)
619 : document.querySelector<HTMLElement>('.VPDoc') ?? undefined)
620 if (searchNavigated) highlightSearchResult(scrollTarget)
488 resetSearchNavigation() 621 resetSearchNavigation()
489 if (openedCollapsible) { 622 if (openedCollapsible) {
490 scrollToElement(openedCollapsible, false) 623 scrollToElement(openedCollapsible, false)
@@ -512,6 +645,7 @@ const tryOpenAnchoredContent = async () => {
512 645
513 if (searchNavigated) { 646 if (searchNavigated) {
514 await openCollapsibles(target) 647 await openCollapsibles(target)
648 highlightSearchResult(target)
515 const collapsiblePath = getOpenCollapsiblePath(target) 649 const collapsiblePath = getOpenCollapsiblePath(target)
516 if (collapsiblePath.length) { 650 if (collapsiblePath.length) {
517 const tabPath = getEnclosingTabPath(target) 651 const tabPath = getEnclosingTabPath(target)
@@ -1107,12 +1241,14 @@ function setupManualCopyButtons() {
1107 wrapTablesInRoot(node) 1241 wrapTablesInRoot(node)
1108 initCopyButtonsInRoot(node) 1242 initCopyButtonsInRoot(node)
1109 if (faviconsEnabled.value) applyFavicons(node) 1243 if (faviconsEnabled.value) applyFavicons(node)
1244 reapplyHighlightIfNeeded(node)
1110 } else { 1245 } else {
1111 node.querySelectorAll<HTMLElement>('.plugin-tabs--content').forEach( 1246 node.querySelectorAll<HTMLElement>('.plugin-tabs--content').forEach(
1112 (panel) => { 1247 (panel) => {
1113 wrapTablesInRoot(panel) 1248 wrapTablesInRoot(panel)
1114 initCopyButtonsInRoot(panel) 1249 initCopyButtonsInRoot(panel)
1115 if (faviconsEnabled.value) applyFavicons(panel) 1250 if (faviconsEnabled.value) applyFavicons(panel)
1251 reapplyHighlightIfNeeded(panel)
1116 } 1252 }
1117 ) 1253 )
1118 } 1254 }
@@ -1124,7 +1260,11 @@ function setupManualCopyButtons() {
1124 1260
1125watch( 1261watch(
1126 () => route.path, 1262 () => route.path,
1127 () => nextTick(() => { initTitleOnly(); setupManualCopyButtons() }), 1263 () => {
1264 highlightTerm = ''
1265 highlightTabPath = null
1266 nextTick(() => { initTitleOnly(); setupManualCopyButtons() })
1267 },
1128 { flush: 'post' } 1268 { flush: 'post' }
1129) 1269)
1130 1270
@@ -1448,4 +1588,4 @@ onUnmounted(() => {
1448 </span> 1588 </span>
1449 </template> 1589 </template>
1450 </Layout> 1590 </Layout>
1451</template> 1591</template>\ No newline at end of file
docs/.vitepress/theme/components/Search.vue +105 −47
@@ -25,7 +25,6 @@ import {
25 onKeyStroke, 25 onKeyStroke,
26 useElementBounding, 26 useElementBounding,
27 useEventListener, 27 useEventListener,
28 useLocalStorage,
29 useScrollLock, 28 useScrollLock,
30 useSessionStorage, 29 useSessionStorage,
31 watchDebounced 30 watchDebounced
@@ -45,6 +44,7 @@ import {
45 Clock, 44 Clock,
46 File, 45 File,
47 Globe, 46 Globe,
47 Highlighter,
48 Hash, 48 Hash,
49 Layers, 49 Layers,
50 LayoutList, 50 LayoutList,
@@ -65,6 +65,16 @@ import { useData } from '../composables/search/use-data'
65import { useEffects } from '../composables/useEffects' 65import { useEffects } from '../composables/useEffects'
66import { applyFavicons, useFavicons } from '../composables/useFavicons' 66import { applyFavicons, useFavicons } from '../composables/useFavicons'
67import { registerGlobalComponents } from '../globalComponents' 67import { registerGlobalComponents } from '../globalComponents'
68import {
69 excerptPreload,
70 saveHistoryEnabled,
71 searchHistory,
72 searchMode,
73 searchResultHighlightMode,
74 showDetailedList,
75 type SearchHistoryEntry,
76 type SearchSortMode
77} from '../searchState'
68import { enhanceAppWithTabs } from './tabs' 78import { enhanceAppWithTabs } from './tabs'
69 79
70export interface FooterTranslations { 80export interface FooterTranslations {
@@ -265,23 +275,6 @@ watch(filterText, (v) => {
265}) 275})
266onBeforeUnmount(() => clearTimeout(urlDebounceTimer)) 276onBeforeUnmount(() => clearTimeout(urlDebounceTimer))
267 277
268const showDetailedList = useLocalStorage(
269 'vitepress:local-search-detailed-list',
270 true
271)
272
273// Three search modes: 'exact' | 'fuzzy' | 'url'
274const searchMode = useLocalStorage<'exact' | 'fuzzy' | 'url'>(
275 'vitepress:local-search-mode',
276 'exact'
277)
278
279// How many result pages get their excerpts rendered ahead of time
280const excerptPreload = useLocalStorage<'off' | 'next' | 'all'>(
281 'vitepress:local-search-excerpt-preload',
282 'off'
283)
284
285// Cycle through modes on mobile (only active button is visible, tap it to advance) 278// Cycle through modes on mobile (only active button is visible, tap it to advance)
286function cycleSearchMode() { 279function cycleSearchMode() {
287 const modes = ['exact', 'fuzzy', 'url'] as const 280 const modes = ['exact', 'fuzzy', 'url'] as const
@@ -293,31 +286,22 @@ function cycleSearchMode() {
293const matchExact = computed(() => searchMode.value === 'exact') 286const matchExact = computed(() => searchMode.value === 'exact')
294const urlSearchMode = computed(() => searchMode.value === 'url') 287const urlSearchMode = computed(() => searchMode.value === 'url')
295 288
296// Search history
297interface SearchHistoryEntry {
298 query: string
299 mode: SearchMode
300 path?: string[]
301 href?: string
302}
303
304const saveHistoryEnabled = useLocalStorage('vitepress:local-search-save-history', false)
305
306const searchHistory = useLocalStorage<SearchHistoryEntry[]>(
307 'vitepress:local-search-history',
308 []
309)
310
311const showHistory = computed( 289const showHistory = computed(
312 () => !filterText.value && searchHistory.value.length > 0 290 () => !filterText.value && searchHistory.value.length > 0
313) 291)
314 292
315function saveToHistory(query: string, mode: SearchMode, path?: string[], href?: string) { 293function saveToHistory(
294 query: string,
295 mode: SearchSortMode,
296 path?: string[],
297 href?: string,
298 resultText?: string
299) {
316 const trimmed = query.trim() 300 const trimmed = query.trim()
317 if (!trimmed || !saveHistoryEnabled.value) return 301 if (!trimmed || !saveHistoryEnabled.value) return
318 const pathKey = (path ?? []).join('\n') 302 const pathKey = (path ?? []).join('\n')
319 searchHistory.value = [ 303 searchHistory.value = [
320 { query: trimmed, mode, path, href }, 304 { query: trimmed, mode, path, href, resultText },
321 ...searchHistory.value.filter( 305 ...searchHistory.value.filter(
322 (h) => !(h.query === trimmed && h.mode === mode && (h.path ?? []).join('\n') === pathKey) 306 (h) => !(h.query === trimmed && h.mode === mode && (h.path ?? []).join('\n') === pathKey)
323 ) 307 )
@@ -331,7 +315,9 @@ function removeFromHistory(index: number) {
331function applyHistory(entry: SearchHistoryEntry) { 315function applyHistory(entry: SearchHistoryEntry) {
332 if (entry.href) { 316 if (entry.href) {
333 window.dispatchEvent( 317 window.dispatchEvent(
334 new CustomEvent('search-nav', { detail: { query: entry.query } }) 318 new CustomEvent('search-nav', {
319 detail: { query: entry.query, resultText: entry.resultText }
320 })
335 ) 321 )
336 router.go(entry.href) 322 router.go(entry.href)
337 showSearch.value = false 323 showSearch.value = false
@@ -347,7 +333,12 @@ const showSettingsPopup = ref(false)
347const settingsButtonRef = ref<HTMLButtonElement>() 333const settingsButtonRef = ref<HTMLButtonElement>()
348const settingsPopupRef = ref<HTMLDivElement>() 334const settingsPopupRef = ref<HTMLDivElement>()
349const settingsBounding = useElementBounding(settingsButtonRef) 335const settingsBounding = useElementBounding(settingsButtonRef)
350type HelpSection = 'search' | 'view' | 'preload' | 'history' 336type HelpSection =
337 | 'search'
338 | 'view'
339 | 'preload'
340 | 'highlight'
341 | 'history'
351const activeHelpSection = ref<HelpSection | null>(null) 342const activeHelpSection = ref<HelpSection | null>(null)
352const helpPopupEl = ref<HTMLDivElement>() 343const helpPopupEl = ref<HTMLDivElement>()
353const helpPopupPos = ref({ top: -9999, left: -9999 }) 344const helpPopupPos = ref({ top: -9999, left: -9999 })
@@ -651,8 +642,6 @@ const pageMeta = (() => {
651 return map 642 return map
652})() 643})()
653 644
654type SearchMode = 'exact' | 'fuzzy' | 'url'
655
656interface TextSearchWorkerPayload { 645interface TextSearchWorkerPayload {
657 results: (SearchResult & Result)[] 646 results: (SearchResult & Result)[]
658 terms: string[] 647 terms: string[]
@@ -674,7 +663,7 @@ interface LoadIndexWorkerRequest {
674interface TextSearchWorkerRequest { 663interface TextSearchWorkerRequest {
675 type: 'text-search' 664 type: 'text-search'
676 query: string 665 query: string
677 mode: SearchMode 666 mode: SearchSortMode
678 pageOrderEntries: [string, number][] 667 pageOrderEntries: [string, number][]
679} 668}
680 669
@@ -1797,9 +1786,11 @@ function getSearchResultHref(item: SearchResult & Result) {
1797} 1786}
1798 1787
1799function navigateToUrlResult(item: UrlResult) { 1788function navigateToUrlResult(item: UrlResult) {
1800 saveToHistory(filterText.value, searchMode.value, [getPageLabel(item.pageId), ...item.titles, item.linkText].map(toHistoryPathHtml).filter(Boolean), buildResultHref(item.pageId, item.tabs, item.anchor)) 1789 saveToHistory(filterText.value, searchMode.value, [getPageLabel(item.pageId), ...item.titles, item.linkText].map(toHistoryPathHtml).filter(Boolean), buildResultHref(item.pageId, item.tabs, item.anchor), item.linkText)
1801 window.dispatchEvent( 1790 window.dispatchEvent(
1802 new CustomEvent('search-nav', { detail: { query: filterText.value } }) 1791 new CustomEvent('search-nav', {
1792 detail: { query: filterText.value, resultText: item.linkText }
1793 })
1803 ) 1794 )
1804 router.go(buildResultHref(item.pageId, item.tabs, item.anchor)) 1795 router.go(buildResultHref(item.pageId, item.tabs, item.anchor))
1805 showSearch.value = false 1796 showSearch.value = false
@@ -1837,10 +1828,10 @@ onKeyStroke('Enter', (e) => {
1837 } 1828 }
1838 1829
1839 if (selectedPackage) { 1830 if (selectedPackage) {
1840 saveToHistory(filterText.value, searchMode.value, [getPageLabel(getPageKey(String(selectedPackage.id))), ...selectedPackage.titles, selectedPackage.title].map(toHistoryPathHtml).filter(Boolean), getSearchResultHref(selectedPackage)) 1831 saveToHistory(filterText.value, searchMode.value, [getPageLabel(getPageKey(String(selectedPackage.id))), ...selectedPackage.titles, selectedPackage.title].map(toHistoryPathHtml).filter(Boolean), getSearchResultHref(selectedPackage), selectedPackage.title)
1841 window.dispatchEvent( 1832 window.dispatchEvent(
1842 new CustomEvent('search-nav', { 1833 new CustomEvent('search-nav', {
1843 detail: { query: filterText.value } 1834 detail: { query: filterText.value, resultText: selectedPackage.title }
1844 }) 1835 })
1845 ) 1836 )
1846 router.go(getSearchResultHref(selectedPackage)) 1837 router.go(getSearchResultHref(selectedPackage))
@@ -1849,10 +1840,10 @@ onKeyStroke('Enter', (e) => {
1849}) 1840})
1850 1841
1851function onResultClick(item: SearchResult & Result) { 1842function onResultClick(item: SearchResult & Result) {
1852 saveToHistory(filterText.value, searchMode.value, [getPageLabel(getPageKey(String(item.id))), ...item.titles, item.title].map(toHistoryPathHtml).filter(Boolean), getSearchResultHref(item)) 1843 saveToHistory(filterText.value, searchMode.value, [getPageLabel(getPageKey(String(item.id))), ...item.titles, item.title].map(toHistoryPathHtml).filter(Boolean), getSearchResultHref(item), item.title)
1853 window.dispatchEvent( 1844 window.dispatchEvent(
1854 new CustomEvent('search-nav', { 1845 new CustomEvent('search-nav', {
1855 detail: { query: filterText.value } 1846 detail: { query: filterText.value, resultText: item.title }
1856 }) 1847 })
1857 ) 1848 )
1858 showSearch.value = false 1849 showSearch.value = false
@@ -2747,6 +2738,54 @@ function onMouseMove(e: MouseEvent) {
2747 </button> 2738 </button>
2748 </div> 2739 </div>
2749 </div> 2740 </div>
2741 <div class="settings-section">
2742 <div class="settings-section-header">
2743 <div class="settings-section-label">
2744 <Highlighter :size="14" stroke-width="1.75" />
2745 Highlight
2746 </div>
2747 <button
2748 type="button"
2749 class="settings-help-btn"
2750 :class="{ active: activeHelpSection === 'highlight' }"
2751 aria-label="Search result highlight help"
2752 @click.stop="toggleHelpSection('highlight', $event)"
2753 @mouseenter="onHelpEnter('highlight', $event)"
2754 @mouseleave="onHelpLeave"
2755 >
2756 <span class="i-carbon:help-filled settings-help-icon" />
2757 </button>
2758 </div>
2759 <div
2760 class="settings-options"
2761 :class="{ 'is-highlighted': activeHelpSection === 'highlight' }"
2762 >
2763 <button
2764 type="button"
2765 class="settings-option"
2766 :class="{ active: searchResultHighlightMode === 'soft' }"
2767 @click="searchResultHighlightMode = 'soft'"
2768 >
2769 <span>Soft</span>
2770 </button>
2771 <button
2772 type="button"
2773 class="settings-option"
2774 :class="{ active: searchResultHighlightMode === 'solid' }"
2775 @click="searchResultHighlightMode = 'solid'"
2776 >
2777 <span>Solid</span>
2778 </button>
2779 <button
2780 type="button"
2781 class="settings-option"
2782 :class="{ active: searchResultHighlightMode === 'off' }"
2783 @click="searchResultHighlightMode = 'off'"
2784 >
2785 <span>Off</span>
2786 </button>
2787 </div>
2788 </div>
2750 <div class="settings-section"> 2789 <div class="settings-section">
2751 <div class="settings-section-header"> 2790 <div class="settings-section-header">
2752 <div class="settings-section-label"> 2791 <div class="settings-section-label">
@@ -2870,6 +2909,25 @@ function onMouseMove(e: MouseEvent) {
2870 </div> 2909 </div>
2871 </div> 2910 </div>
2872 </template> 2911 </template>
2912 <template v-else-if="activeHelpSection === 'highlight'">
2913 <h4 class="sh-title">
2914 <Highlighter :size="16" stroke-width="1.75" class="sh-title-icon" />
2915 Search Result Highlight
2916 </h4>
2917 <p class="sh-desc">
2918 Highlights the exact result you open.
2919 </p>
2920 <div class="sh-options">
2921 <div class="sh-option">
2922 <strong>Soft</strong>
2923 <span>Soft accent background with a solid border.</span>
2924 </div>
2925 <div class="sh-option">
2926 <strong>Solid</strong>
2927 <span>Solid accent fill with no border.</span>
2928 </div>
2929 </div>
2930 </template>
2873 <template v-else-if="activeHelpSection === 'history'"> 2931 <template v-else-if="activeHelpSection === 'history'">
2874 <h4 class="sh-title"> 2932 <h4 class="sh-title">
2875 <Clock :size="16" stroke-width="1.75" class="sh-title-icon" /> 2933 <Clock :size="16" stroke-width="1.75" class="sh-title-icon" />
@@ -3974,4 +4032,4 @@ html.effects-disabled .clear-button:active {
3974 color: var(--vp-c-text-1); 4032 color: var(--vp-c-text-1);
3975 opacity: 1; 4033 opacity: 1;
3976} 4034}
3977</style> 4035</style>\ No newline at end of file
docs/.vitepress/theme/searchState.ts +46 −1
@@ -1,7 +1,52 @@
1import { useLocalStorage } from '@vueuse/core'
1import { ref } from 'vue' 2import { ref } from 'vue'
2 3
4
5export type SearchResultHighlightMode = 'off' | 'soft' | 'solid'
6export type SearchSortMode = 'exact' | 'fuzzy' | 'url'
7export type SearchExcerptPreload = 'off' | 'next' | 'all'
8
9export interface SearchHistoryEntry {
10 query: string
11 mode: SearchSortMode
12 path?: string[]
13 href?: string
14 resultText?: string
15}
16
3export const searchOpen = ref(false) 17export const searchOpen = ref(false)
4 18
19export const searchResultHighlightMode = useLocalStorage<SearchResultHighlightMode>(
20 'vitepress:local-search-result-highlight',
21 'off'
22)
23
24export const showDetailedList = useLocalStorage(
25 'vitepress:local-search-detailed-list',
26 true
27)
28
29export const searchMode = useLocalStorage<SearchSortMode>(
30 'vitepress:local-search-mode',
31 'exact'
32)
33
34// How many result pages get their excerpts rendered ahead of time
35export const excerptPreload = useLocalStorage<SearchExcerptPreload>(
36 'vitepress:local-search-excerpt-preload',
37 'off'
38)
39
40export const saveHistoryEnabled = useLocalStorage(
41 'vitepress:local-search-save-history',
42 false
43)
44
45export const searchHistory = useLocalStorage<SearchHistoryEntry[]>(
46 'vitepress:local-search-history',
47 []
48)
49
5export function openSearch() { 50export function openSearch() {
6 searchOpen.value = true 51 searchOpen.value = true
7} 52}\ No newline at end of file
docs/.vitepress/theme/styles/style.scss +30 −1
@@ -192,6 +192,35 @@ $ease-in-expo: cubic-bezier(0.7, 0, 0.84, 0);
192 --vp-badge-danger-bg: theme("colors.carnation.950"); 192 --vp-badge-danger-bg: theme("colors.carnation.950");
193} 193}
194 194
195.search-result-highlight {
196 display: inline-block;
197 position: relative;
198 padding: 0 0.25em;
199 border: 1px solid var(--vp-c-brand-1);
200 border-radius: 4px;
201 background-color: var(--vp-collapsible-bg);
202 color: var(--vp-c-brand-1);
203 font-size: 0.9em;
204 font-weight: 600;
205 line-height: 1.5;
206 white-space: nowrap;
207 vertical-align: baseline;
208}
209
210.search-result-highlight--solid {
211 border: none;
212 background-color: var(--vp-c-brand-1);
213 color: var(--vp-button-brand-text);
214}
215
216html:not(.dark) .search-result-highlight {
217 color: #fff;
218}
219
220html.dark .search-result-highlight {
221 color: #000;
222}
223
195.vp-doc a { 224.vp-doc a {
196 color: var(--vp-c-brand-2); 225 color: var(--vp-c-brand-2);
197 text-decoration: underline; 226 text-decoration: underline;
@@ -2082,4 +2111,4 @@ html:not(.dark) .nolebase-ui-input-horizontal-option {
2082.screen-menu-social-links { 2111.screen-menu-social-links {
2083 padding-top: 8px; 2112 padding-top: 8px;
2084 border-top: 1px solid var(--vp-c-divider); 2113 border-top: 1px solid var(--vp-c-divider);
2085} 2114}\ No newline at end of file