mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(cli): support custom facetFilters
This commit is contained in:
parent
82ce590eb8
commit
b84fe21baa
@ -26,9 +26,17 @@ export default {
|
||||
},
|
||||
|
||||
mounted() {
|
||||
if (this.searchConfig) {
|
||||
const { searchConfig } = this;
|
||||
if (searchConfig) {
|
||||
const { algoliaOptions } = searchConfig;
|
||||
let facetFilters = [`lang:${this.lang}`];
|
||||
|
||||
if (algoliaOptions?.facetFilters) {
|
||||
facetFilters = facetFilters.concat(algoliaOptions.facetFilters);
|
||||
}
|
||||
|
||||
this.docsearchInstance = window.docsearch({
|
||||
...this.searchConfig,
|
||||
...searchConfig,
|
||||
transformData: (hits) => {
|
||||
hits.forEach((hit) => {
|
||||
if (hit.anchor) {
|
||||
@ -36,13 +44,14 @@ export default {
|
||||
hit.anchor = null;
|
||||
}
|
||||
});
|
||||
if (this.searchConfig.transformData) {
|
||||
this.searchConfig.transformData(hits);
|
||||
if (searchConfig.transformData) {
|
||||
searchConfig.transformData(hits);
|
||||
}
|
||||
},
|
||||
inputSelector: '.van-doc-search',
|
||||
algoliaOptions: {
|
||||
facetFilters: [`lang:${this.lang}`],
|
||||
...algoliaOptions,
|
||||
facetFilters,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user