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

enhancing DocSearch integration with language #697

Merged
merged 1 commit into from
Aug 7, 2018

Conversation

s-pace
Copy link
Contributor

@s-pace s-pace commented Aug 2, 2018

Summary
We want to introduce the new way DocSearch will handle search on different languages for vuepress.

It will not more be needed to use the URL as it might introduce issue. We will grab it ourselves from the DOM (attribute lang).

You can now update the vuepress website (couldn't find the website's repo):

<!-- at the end of the HEAD -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />

<!-- at the end of the BODY -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<script type="text/javascript"> docsearch({
  apiKey: '3a539aab83105f01761a137c61004d85',
  indexName: 'vuepress',
  inputSelector: '### REPLACE ME ####',
  algoliaOptions: { 'facetFilters': ["lang:$LANG"] },
  debug: false // Set debug to true if you want to inspect the dropdown
});
</script>
  • Add a search input in your page if you don't have any yet. Then update the inputSelector value in JS snippet to a CSS selector that targets your search input field.

  • Replace $LANG with the lang you want to search on.
    So as of today you have: en-US, zh-CN

What kind of change does this PR introduce? (check at least one)

  • Feature
  • Docs

We do update the Documentation's references.

Does this PR introduce a breaking change? (check one)

  • No

CC #686

Copy link
Member

@ulivz ulivz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your great work.


Q: Why can't you find the website's repo?
A: Because VuePress is built by Netlify.

@ulivz ulivz merged commit 0d581c4 into vuejs:master Aug 7, 2018
ulivz added a commit that referenced this pull request Aug 7, 2018
@s-pace
Copy link
Contributor Author

s-pace commented Aug 8, 2018

thanks @ulivz

How can we help you to integrate back the DocSearch JS snippet within the documentation website then?

@s-pace
Copy link
Contributor Author

s-pace commented Aug 8, 2018

You can discard my last comment. Solved by #686 (comment)

s-pace pushed a commit to s-pace/vuepress that referenced this pull request Sep 3, 2019
@s-pace s-pace mentioned this pull request Sep 3, 2019
@s-pace s-pace deleted the feat/better_docsearch_integration branch September 3, 2019 08:27
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

Successfully merging this pull request may close these issues.

2 participants