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

Add algolia search #963

Merged
merged 2 commits into from
Dec 3, 2020
Merged

Add algolia search #963

merged 2 commits into from
Dec 3, 2020

Conversation

keynmol
Copy link
Contributor

@keynmol keynmol commented Nov 28, 2020

Closes #962

To Algolia's credit, adding this was 5 minutes of following instructions and a whole day of CSS. Mostly because layout.html didn't do anything for some reason, so I had to add and remove lots of custom css.

Plus there's duplication of .st pages.

In the end I removed all the custom CSS and decided to make Algolia's base bootstrap theme to work properly first.

Outstanding:

  • @eed3si9n to apply for docsearch here: https://docsearch.algolia.com/docs/apply (sorry for picking on you Eugene, not sure what the full list of maintainers looks like :-)

    Given that API key is public, once there's one I'll be able to test this locally without having to merge 🎉

  • Some CSS tweaks to match the theme?

  • Might be able to add language-localised to pages not in English, if it's worth it? I don't know how DocSearch's indexing works

Here's what it looks now with index pointing at scala-lang.org DocSearch

  1. Reference pages
    image
  2. Langing page
    image

@lightbend-cla-validator

Hi @keynmol,

Thank you for your contribution! We really value the time you've taken to put this together.

Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement:

https://www.lightbend.com/contribute/cla

@eed3si9n
Copy link
Member

For the record I did apply for DocSearch yesterday. Since it's Thanksgiving weekend, it might take a few days to process?

@keynmol
Copy link
Contributor Author

keynmol commented Nov 28, 2020

Ah yes, you're right. Either way, the wheels are turning and SBT site should be at the top of priority list as it's open source :)

@eed3si9n
Copy link
Member

eed3si9n commented Dec 3, 2020

Hello! I got the API key.

<!-- 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: 'e47ee877a07ea1c48722f08430d54913',
indexName: 'scala-sbt',
inputSelector: '### REPLACE ME ####',
algoliaOptions: { 'facetFilters': ["lang:$LANG"] },
debug: false // Set debug to true if you want to inspect the dropdown
});
</script>

@eed3si9n
Copy link
Member

eed3si9n commented Dec 3, 2020

@keynmol
Copy link
Contributor Author

keynmol commented Dec 3, 2020

Yohoo!

Let me update the PR and see what sort of results we get.

I can also push the locally generated version termporarily to http://surge.sh so that you can have a play around

@keynmol
Copy link
Contributor Author

keynmol commented Dec 3, 2020

Perhaps the indexing hasn't happened yet - I've pushed the site with new configs here: http://scala-sbt.surge.sh/index.html

I can see requests going to algolia okay but the response doesn't contain any results.

I'll see if the regex in their sbt config is correct.

@keynmol
Copy link
Contributor Author

keynmol commented Dec 3, 2020

A-ha, the regex is indeed incorrect. It collects everything after /docs into a lang facet filter.

Which means if I remove the facet filter the search should work.

@keynmol
Copy link
Contributor Author

keynmol commented Dec 3, 2020

We're live! (I pushed the change to the the http://scala-sbt.surge.sh/1.x/docs/ as well)

image

But lack of facet does mean that visitors will learn a language or two :)

image

Copy link
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

Thanks!

@eed3si9n eed3si9n merged commit 6135cc3 into sbt:develop Dec 3, 2020
@keynmol keynmol deleted the add-algolia-search branch December 3, 2020 20:56
@eed3si9n eed3si9n mentioned this pull request Jan 24, 2021
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.

Join algolia's DocSearch program
3 participants