-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Algolia DocSearch Integration #201
Conversation
docs/.vuepress/config.js
Outdated
@@ -28,6 +28,12 @@ module.exports = { | |||
repo: 'vuejs/vuepress', | |||
editLinks: true, | |||
docsDir: 'docs', | |||
algolia: { | |||
appId: 'BH4D9OD16A', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the appId and apiKey be committed as part of the repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your concern, but I have commented at this PR's summary:
Need to clean config ... before merged.
Still have some consideration for this feature, only one |
Seeing so many css reset, I decided to fallback to [email protected] that the official website uses. |
LGTM. Let's remove the config. |
Oh nvm, if you are still working on it please let me know when you finish. |
I think we should use the latest version of docsearch if possible. CSS resets are not that much of a problem. |
OK, please wait for a moment. I need to limit the width of the mobile phone and test again. |
@yyx990803 finished for it. now it looks good at mobile. Another problem, I found that our search box displayed not very well at ipad's portrait view, I will fix it at another story. |
Can you add documentation for the |
lib/default-theme/Navbar.vue
Outdated
@@ -12,7 +12,7 @@ | |||
</span> | |||
</router-link> | |||
<div class="links"> | |||
<AlgoliaSearchBox v-if="isAlgoliaSearch" :options="$site.themeConfig.algolia"/> | |||
<AlgoliaSearchBox v-if="isAlgoliaSearch" :options="algolia"/> | |||
<SearchBox v-if="isSearch"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be v-else-if="$site.themeConfig.search !== false"
here
docs/zh/config/README.md
Outdated
- 类型: `Object` | ||
- 默认值: `undefined` | ||
|
||
使用 `algolia` 选项可以让你禁用掉默认的基于 headers 的搜索,从而使用 [algolia docsearch](https://github.com/algolia/docsearch)。为了使其生效,你必须提供至少 `apiKey` 和 `indexName` 这两个选项: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...可以让你用 algolia search 取代默认的...
docs/zh/config/README.md
Outdated
} | ||
``` | ||
|
||
其他可用的选项可以参考 [docsearch options](https://github.com/algolia/docsearch#docsearch-options)。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"请"参考
lib/default-theme/Navbar.vue
Outdated
@@ -12,19 +12,33 @@ | |||
</span> | |||
</router-link> | |||
<div class="links"> | |||
<SearchBox v-if="$site.themeConfig.search !== false"/> | |||
<AlgoliaSearchBox v-if="isAlgoliaSearch" :options="algolia"/> | |||
<SearchBox v-if="isSearch"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以用 v-else-if="$site.themeConfig.search !== false"
initialize () { | ||
Promise.all([ | ||
import(/* webpackChunkName: "docsearch" */ 'docsearch.js/dist/cdn/docsearch.min.js'), | ||
import(/* webpackChunkName: "docsearch" */ 'docsearch.js/dist/cdn/docsearch.min.css') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在的 webpack 配置会把所有 css 都抽取出来,即使用 dynamic import 也没用。这样的话不论用不用 algolia 都会加载这些 css。有一个办法是在 createBaseConfig 的时候如果用户没有使用 algolia 则直接把 AlgoliaSearchBox alias 到一个空 module, 这样可以彻底避免把这个组件打包进去。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
厉害了,我还没注意这个
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
哈哈哈哈哈,突然说中文 XD
莫名的可爱(●'◡'●)
Thanks for informing me of this detail, addressed all comments at 88f7435 And a simple size test:
A great promotion! thank you! |
It looks like Also, could some description be added on how the content is inserted into Algolia? I am not getting any search results right now, do I need to add records to the index myself? |
@jerome2710 Have you submitted your site to Algolia for them to begin indexing your content? |
Hi @bencodezen, thank you for your reply. No, I was unaware Algolia needed to scrape the docs-domain to index the content. I just submitted the site! Maybe add this to the documentation as well? |
@jerome2710 Here's the PR for the docs update: 6082bc1 Let me know if the language isn't clear enough! |
@bencodezen Very useful, thank you! Should we mention the |
@jerome2710 I'm currently using Algolia for VueMeetups.org https://github.com/VueMeetups/vuemeetups.org and did not configure an appId. Could you send me a gist or something to show what you're talking about? |
@bencodezen Interesting to hear that it does work for you. I am using v0.10.2 of Vuepress and that includes the Algolia npm-package of docsearch.js with v2.5.2. As you can see here, the constructor falls back to an default appId. This causes an appId/apiKey mismatch for me if I omit it in the config.js of Vuepress. |
Basically completed, welcome to test and feel free to give your comments.