From a872a070e457c6113ef490c3623b5d7dca51aec2 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sat, 26 Sep 2020 22:44:40 +0800 Subject: [PATCH] fix(cli): docsearch anchor not work --- .../vant-cli/site/desktop/components/SearchInput.vue | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/vant-cli/site/desktop/components/SearchInput.vue b/packages/vant-cli/site/desktop/components/SearchInput.vue index 103f74adc..31b239873 100644 --- a/packages/vant-cli/site/desktop/components/SearchInput.vue +++ b/packages/vant-cli/site/desktop/components/SearchInput.vue @@ -29,6 +29,17 @@ export default { if (this.searchConfig) { this.docsearchInstance = window.docsearch({ ...this.searchConfig, + transformData: (hits) => { + hits.forEach((hit) => { + if (hit.anchor) { + hit.url = hit.url + '#' + hit.anchor; + hit.anchor = null; + } + }); + if (this.searchConfig.transformData) { + this.searchConfig.transformData(hits); + } + }, inputSelector: '.van-doc-search', algoliaOptions: { facetFilters: [`lang:${this.lang}`],