docs/.vitepress/theme/searchState.ts

c5d5a5e6d8127763d92162dd39b34a6092451d93
wotaku/docs/.vitepress/theme/searchState.ts

59 lines · 1392 bytes

 1import { useLocalStorage } from '@vueuse/core'
 2import { ref } from 'vue'
 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
17export const searchOpen = ref(false)
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
50export type RibbonStyle = 'tabs' | 'list'
51
52export const ribbonStyle = useLocalStorage<RibbonStyle>(
53  'vitepress:local-search-ribbon-style',
54  'list'
55)
56
57export function openSearch() {
58  searchOpen.value = true
59}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form