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

feat: add Algolia DocSearch to documentation site #54

Merged
merged 4 commits into from
Mar 25, 2022

Conversation

giladgd
Copy link
Contributor

@giladgd giladgd commented Mar 21, 2022

Description

Added Algolia DocSearch to the documentation site

The screenshots below use the testing apiKey provided by Algolia

In order for the search to actually work you have to do the following:

  1. Go to https://docsearch.algolia.com/apply/ and register TypeORM, it's free for open-source projects.
  2. Edit apiKey, appId and indexName in script/component/MainPage.js with the values provided to you by Algolia.

Closes: #16

Changed Vue router's mode from "hash" to "history" to support search engine indexing

Previously site URLs looked like this:

https://typeorm.io/#/data-source
https://typeorm.io/#/data-source/how-to-use-datasource

Now site URLs will look like this:

https://typeorm.io/data-source
https://typeorm.io/data-source#how-to-use-datasource

The previous URLs will continue to work but will now redirect to the new URLs.
In order to prevent getting a 404 error when opening a deep URL, a custom 404.html page is implemented to redirect back to index.html which will then use the history API to load the original URL without a refresh.

Based on #36

Screenshots

localhost_3000_ (2)

localhost_3000_ (3)

localhost_3000_ (4)

The `apiKey`, `appId` and `indexName` parameters specified in `MainPage.js` should be updated in order for the search to work
@giladgd
Copy link
Contributor Author

giladgd commented Mar 23, 2022

@pleerock Please let me know if I could help in any way to merge this feature

@pleerock
Copy link
Member

Here is what I got from the email:

CSS
Copy this snippet at the end of the HTML tag

JavaScript
Copy this snippet at the end of the HTML tag

<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@3"></script> <script type="text/javascript"> docsearch({ appId: 2UUKVSBT3M, apiKey: 8392de2c2e76d873b60bf10562aab788, indexName: typeorm, container: '### REPLACE ME WITH A CONTAINER (e.g. div) ###' debug: false // Set debug to true if you want to inspect the modal }); </script>

I guess you can now finish this PR.

@giladgd
Copy link
Contributor Author

giladgd commented Mar 24, 2022

@pleerock I've updated the PR with the apiKey, but it seems that the data index should also be configured at Algolia so the search can find results also from pages other than just the main page.
You can experiment with its configuration here and here.

If you like, you can add me to the TypeORM index team at Algolia (here) so I can experiment with the configuration and make it work well with the way the documentation site works

…arch engine indexing

In order to support loading a deep url without getting a 404 error, a custom 404.html page is implemented to redirect back to index.html which uses history api to load the original url without a refresh.
Based on typeorm#36
@giladgd
Copy link
Contributor Author

giladgd commented Mar 24, 2022

@pleerock I think setting this config would make the search work across all pages after merging this PR

@pleerock pleerock merged commit a2ab2d6 into typeorm:master Mar 25, 2022
@pleerock
Copy link
Member

thank you!

@giladgd
Copy link
Contributor Author

giladgd commented Apr 4, 2022

@pleerock It seems like the search doesn't index the documentation correctly.
Can you please add me to the documentation crawler account so I can try to fix it?
You can do it here: https://crawler.algolia.com/

@pleerock
Copy link
Member

pleerock commented Apr 5, 2022

@giladgd done!

@giladgd
Copy link
Contributor Author

giladgd commented Apr 5, 2022

@pleerock The search is working now, you can remove me from the crawler account now if you like.
PR #57 should add proper titles to some results.

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.

Search
2 participants