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