|
|
@ -14,7 +14,8 @@ import { useSiteDataByRoute } from 'vitepress'
|
|
|
|
const siteData = useSiteDataByRoute()
|
|
|
|
const siteData = useSiteDataByRoute()
|
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
const props = defineProps<{
|
|
|
|
options: DefaultTheme.AlgoliaSearchOptions
|
|
|
|
options: DefaultTheme.AlgoliaSearchOptions,
|
|
|
|
|
|
|
|
multilang?: boolean
|
|
|
|
}>()
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
|
|
const vm = getCurrentInstance()
|
|
|
|
const vm = getCurrentInstance()
|
|
|
@ -57,6 +58,10 @@ function update(options: any) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function initialize(userOptions: any) {
|
|
|
|
function initialize(userOptions: any) {
|
|
|
|
|
|
|
|
// if the user has multiple locales, the search results should be filtered
|
|
|
|
|
|
|
|
// based on the language
|
|
|
|
|
|
|
|
const facetFilters = props.multilang ? ['language:' + siteData.value.lang] : []
|
|
|
|
|
|
|
|
|
|
|
|
docsearch(
|
|
|
|
docsearch(
|
|
|
|
Object.assign({}, userOptions, {
|
|
|
|
Object.assign({}, userOptions, {
|
|
|
|
container: '#docsearch',
|
|
|
|
container: '#docsearch',
|
|
|
@ -64,7 +69,7 @@ function initialize(userOptions: any) {
|
|
|
|
searchParameters: Object.assign({}, userOptions.searchParameters, {
|
|
|
|
searchParameters: Object.assign({}, userOptions.searchParameters, {
|
|
|
|
// pass a custom lang facetFilter to allow multiple language search
|
|
|
|
// pass a custom lang facetFilter to allow multiple language search
|
|
|
|
// https://github.com/algolia/docsearch-configs/pull/3942
|
|
|
|
// https://github.com/algolia/docsearch-configs/pull/3942
|
|
|
|
facetFilters: ['language:' + siteData.value.lang].concat(
|
|
|
|
facetFilters: facetFilters.concat(
|
|
|
|
userOptions.facetFilters || []
|
|
|
|
userOptions.facetFilters || []
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|