Skip to content

fix(algolia): don't fail to populate search container if one is "missing" - #2699

Open
msvticket wants to merge 1 commit into
google:mainfrom
msvticket:algolia
Open

fix(algolia): don't fail to populate search container if one is "missing"#2699
msvticket wants to merge 1 commit into
google:mainfrom
msvticket:algolia

Conversation

@msvticket

Copy link
Copy Markdown

Not all search containers might exist on a page. In that case an error like this is visible in the console:

Uncaught TypeError: can't access property "__k", t is null
    Ke https://cdn.jsdelivr.net/npm/@docsearch/js@3.8.2:8
    <anonymous> https://cdn.jsdelivr.net/npm/@docsearch/js@3.8.2:8
    <anonymous> https://jx-docs-jx-jayex-io-jx-docs-pr-19.infra.jenkins-x.rocks/:527

If it's #docsearch-0 that is missing, #docsearch-1 won't be populated even if it does exist.

My case

At https://jayex.io/ we are currently using custom code for Algolia but while I'm in the process of upgrading hugo and docsy I'm trying to switch to as much standard features as possible. The result for algolia was that the searchbox disappeared on the front page since it is configured to have no sidebars. Here is a link to my preview: https://jx-docs-jx-jayex-io-jx-docs-pr-19.infra.jenkins-x.rocks/

Maintenance

While fixing this I thought I'd do some maintenance as well:

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.

1 participant