Skip to content

Commit

Permalink
feat(search): support custom disableQueryPersistence in local search (
Browse files Browse the repository at this point in the history
  • Loading branch information
zonemeen committed Apr 24, 2023
1 parent 25b9111 commit 2f0f2d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/client/theme-default/components/VPLocalSearchBox.vue
Expand Up @@ -81,7 +81,16 @@ const searchIndex = computedAsync(async () =>
)
)
const filterText = useSessionStorage('vitepress:local-search-filter', '')
const disableQueryPersistence = computed(() => {
return (
theme.value.search?.provider === 'local' &&
theme.value.search.options?.disableQueryPersistence === true
)
})
const filterText = disableQueryPersistence.value
? ref('')
: useSessionStorage('vitepress:local-search-filter', '')
const showDetailedList = useLocalStorage(
'vitepress:local-search-detailed-list',
Expand Down
5 changes: 5 additions & 0 deletions types/default-theme.d.ts
Expand Up @@ -298,6 +298,11 @@ export namespace DefaultTheme {
*/
disableDetailedView?: boolean

/**
* @default false
*/
disableQueryPersistence?: boolean

translations?: LocalSearchTranslations
locales?: Record<string, Partial<Omit<LocalSearchOptions, 'locales'>>>
}
Expand Down

0 comments on commit 2f0f2d5

Please sign in to comment.