Skip to content

Commit 2f0f2d5

Browse files
authored
feat(search): support custom disableQueryPersistence in local search (#2273)
1 parent 25b9111 commit 2f0f2d5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/client/theme-default/components/VPLocalSearchBox.vue

+10-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,16 @@ const searchIndex = computedAsync(async () =>
8181
)
8282
)
8383
84-
const filterText = useSessionStorage('vitepress:local-search-filter', '')
84+
const disableQueryPersistence = computed(() => {
85+
return (
86+
theme.value.search?.provider === 'local' &&
87+
theme.value.search.options?.disableQueryPersistence === true
88+
)
89+
})
90+
91+
const filterText = disableQueryPersistence.value
92+
? ref('')
93+
: useSessionStorage('vitepress:local-search-filter', '')
8594
8695
const showDetailedList = useLocalStorage(
8796
'vitepress:local-search-detailed-list',

types/default-theme.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ export namespace DefaultTheme {
298298
*/
299299
disableDetailedView?: boolean
300300

301+
/**
302+
* @default false
303+
*/
304+
disableQueryPersistence?: boolean
305+
301306
translations?: LocalSearchTranslations
302307
locales?: Record<string, Partial<Omit<LocalSearchOptions, 'locales'>>>
303308
}

0 commit comments

Comments
 (0)