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

fix: make algolia search work with indices that don't return absolute urls #2956

Merged
merged 1 commit into from Sep 13, 2023
Merged

fix: make algolia search work with indices that don't return absolute urls #2956

merged 1 commit into from Sep 13, 2023

Conversation

frederic-schwarz
Copy link
Contributor

this enables the algolia search plugin to work also with indices crawled by the netlify algolia plugin which, depending on the configuration, can crawl pages with relative paths

relative paths  absolute urls
image image

without the fix, using the algolia search plugin leads to

VPAlgoliaSearchBox.vue:88 Uncaught (in promise) TypeError: Failed to construct 'URL': Invalid URL
   at getRelativePath (VPAlgoliaSearchBox.vue:88:30)

when absolute URLs are provided the fix doesn't change the outcome because

new URL('https://vitepress.dev/guide/what-is-vitepress#what-is-vitepress', 'https://github.com').origin
// 'https://vitepress.dev'

@brc-dd
Copy link
Member

brc-dd commented Sep 13, 2023

LGTM. Quick question though, does the docsearch package works with netlify crawler as well? i.e. does simply providing appId, apiKey, indexName from algolia for netlify works with VitePress?

@frederic-schwarz
Copy link
Contributor Author

LGTM. Quick question though, does the docsearch package works with netlify crawler as well? i.e. does simply providing appId, apiKey, indexName from algolia for netlify works with VitePress?

yes exactly, providing appId, apiKey and indexName is enough to make it work. It also works fine with vuepress-next docsearch plugin because they parse the hit.url differently

@brc-dd brc-dd merged commit 2a34c6b into vuejs:main Sep 13, 2023
7 checks passed
@frederic-schwarz frederic-schwarz deleted the algolia-relative-path branch September 13, 2023 19:28
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants