-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Search correct language for Docusaurus docsearch #744
Conversation
Only search the current version of the docs. Right now there are duplicates because `next` is also searched. https://github.com/facebook/Docusaurus/blob/d28b864a59fabeea45add8c090a13de7d0530de5/lib/core/Site.js#L140 does the replacement
Deploy preview for docusaurus-preview ready! Built with commit 0dfce4a |
Actually we should probably do it for languages too. But the current state is that Only has 'en' for lang and 'next' for version I am currently away so I won't be able to submit PR for it. |
Currently searching both next and latest. Only want latest. Ref: facebook/docusaurus#744
@endiliey I added a PR to Aloglia |
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.
I've pushed a fix to your PR @JoelMarcey
Let's wait for algolia/docsearch-configs#446 to be merged & test it on netlify
website/siteConfig.js
Outdated
@@ -36,6 +36,7 @@ const siteConfig = { | |||
algolia: { | |||
apiKey: '3eb9507824b8be89e7a199ecaa1a9d2c', | |||
indexName: 'docusaurus', | |||
facetFilters: [ "version:VERSION" ], |
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.
Shouldn't it be.
algoliaOptions: {
facetFilters: [ "version:VERSION"]
}
website/siteConfig.js
Outdated
@@ -36,6 +36,7 @@ const siteConfig = { | |||
algolia: { | |||
apiKey: '3eb9507824b8be89e7a199ecaa1a9d2c', | |||
indexName: 'docusaurus', | |||
facetFilters: [ "lang:LANGUAGE", "version:VERSION" ], |
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.
Need algoliaOptions for this to work
https://docusaurus.io/docs/en/next/search.html#enabling-the-search-bar
algoliaOptions: {
facetFilters: ["lang:LANGUAGE", "version:VERSION"]
}
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!
Is this PR being blocked by algolia/docsearch-configs#446? |
@yangshun. Yes, tbh we need to wait ~24 hours after that PR got merged so algolia crawler had finished crawling & we can test this |
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/docsearch-configs#446 only allow latest
version.
When we are at docusaurus non-latest version, the search will not work.
Solution
-
Change "version:VERSION" to "version:latest"
But this means whichever version we are at, we are searching on latest docs only. I think this is unnatural, let's say I'm at docusaurus version 1.05 page, the latest version is 1.2 and language 'en', it will search for the version 1.2 instead of 1.05 -
Change algolia config to include all docusaurus version. (Submit another PR at docsearch-configs)
So when we are at v1.05 and lang 'ko' it will search on that version & language
👋 I am currently trying to tailor you the best configuration in order to have something simple and easy to understand. We are facing two majors issue regarding how we scrap your website:
An easier solution would be to extract the context of the page (version and lang) from the DOM itself. Could it be possible to add meta tags? |
@s-pace Hi 👋 -- sorry this is causing so much trouble. But I am hoping if we solve this correctly for Docusaurus, then sites that use Docusaurus can benefit from what we learned.
I think we can probably do this, maybe. Just any
If we use meta tags:
Thanks! |
Makes sense definitely. Let's try to have something working with it. Using meta tag is fine for us. It will introduce a bit more of complexity within your configuration but we can do it.
This will not change the issue we are struggling with since we receive a
Unfortunately this issue will not be fixed since pages are treated as different pages. The easiest solutions I see:
Yes, we will need to change something from the config anyway. This can be quickly done. |
Which do you prefer ?
If my understanding is right the solution for this is to provide a complete sitemap that only provide pages with or without .html pages (choose only one) So the fix is to generate Sitemap with only .html extension for option A and Sitemap without .html extension for option B At |
I created algolia/docsearch-configs#453 as a short-term fix to this. |
@s-pace I have a PR up for Docusaurus that creates a sitemap depending on whether a config option is set to allow extension-less URLs. So the sitemap will have |
@JoelMarcey Is this good to merge? |
I am not sure we need this now. Or at least the whole thing. Do you see duplicate search results when you search now? Sent with GitHawk |
Actually I never did see duplicate search results before. I'm not seeing it now also. Will let you verify and close it if it's no longer needed. |
I look at it again over the weekend and close, update or merge as appropriate. |
Actually the current state is that whichever our language is at, we always search for english language docs. And whichever version we are currently, we always search for 'latest version' https://github.com/algolia/docsearch-configs/blob/master/configs/docusaurus.json |
Right. I think |
@JoelMarcey Edit: |
ebfbb80
to
0dfce4a
Compare
DocSearch PR merged: <!-- 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: '3eb9507824b8be89e7a199ecaa1a9d2c',
indexName: 'docusaurus',
inputSelector: '### REPLACE ME ####',
algoliaOptions: { 'facetFilters': ["lang:$LANG", "tags:$TAGS"] },
debug: false // Set debug to true if you want to inspect the dropdown
});
</script>
|
Motivation
Only search the current version of the docs. Right now there are duplicates because
next
is also searched.https://github.com/facebook/Docusaurus/blob/d28b864a59fabeea45add8c090a13de7d0530de5/lib/core/Site.js#L140 does the replacement
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
eyes
Related PRs
N/A