Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[website]: 文档搜索会跳转到原 有赞 文档 #11

Open
eviIIt opened this issue Nov 11, 2019 · 1 comment
Open

[website]: 文档搜索会跳转到原 有赞 文档 #11

eviIIt opened this issue Nov 11, 2019 · 1 comment

Comments

@eviIIt
Copy link

eviIIt commented Nov 11, 2019

文档搜索功能点击搜索结果会跳转到有赞的文档.

相关内容

估计需要申请 algolia 账号以及提 pr 到 docsearch-configs

@eviIIt eviIIt changed the title [website]: 文档搜索会跳转到原 有赞 文档 docs: 文档搜索会跳转到原 有赞 文档 Nov 11, 2019
@eviIIt eviIIt changed the title docs: 文档搜索会跳转到原 有赞 文档 [website]: 文档搜索会跳转到原 有赞 文档 Nov 11, 2019
@xrr2016
Copy link

xrr2016 commented Nov 22, 2019

原因

搜索结果中的一项是一个跳转到 https://youzan.github.io/vant a 链接

result

vant 的文档实例化了一个docsearch 对象,搜索结果的 UI 是通过 docsearch 这个实例对象创建出来的。

 mounted() {
    if (this.searchConfig) {
      this.docsearchInstance = window.docsearch({
        ...this.searchConfig,
        inputSelector: '.van-doc-search',
        algoliaOptions: {
          facetFilters: [`lang:${this.lang}`]
        }
      });
    }
  }

SearchInput

而element-ui 的文档的搜索结果是用自己的 autocomplete 组件显示的,点击搜索结果执行 handleSelect 方法

handleSelect

这个方法直接跳转网站内路由,所以不会跳转到 element 官方的文档网站去

解决方案

Docsearch 申请一个 apiKey

image

使用申请到的 key 替换原来的

export const searchConfig = {
  apiKey: '90067aecdaa2c85220e2783cd305caac',
  indexName: 'vant'
};
  1. 使用 docssearch 提供的搜索结果 ui dropdown

  2. 像 element-ui 那样自己开发一个结果展示的 UI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants