typesense / docusaurus-theme-search-typesense

A fork of the awesome @docusaurus/theme-search-algolia library customized to work with Typesense
https://typesense.org/docs/guide/docsearch.html
MIT License
67 stars 15 forks source link

Fix an issue where setting contextualSearch=true breaks the search box #7

Closed octogonz closed 2 years ago

octogonz commented 2 years ago

Change Summary

Problem

  1. Edit your docusaurus.config.js to set contextualSearch: true
  2. Build and deploy your website
  3. Run the https://github.com/typesense/typesense-docsearch-scraper tool to generate the search index

When you try to render the page, search is broken because of a JavaScript error saying that the docusaurus_tag field is missing from the server response. The crawler was looking for an HTML tag like this:

<meta data-react-helmet="true" name="docsearch:docusaurus_tag" content="docs-default-current">

...but it is missing from the HTML pages. Why? The @theme/SearchMetadata hook is supposed to render it.

It is not found because the file path is spelled incorrectly as SearchMetadatas instead of SearchMetadata.

Solution

Rename src/theme/SearchMetadatas/ --> src/theme/SearchMetadata/

PR Checklist

jasonbosco commented 2 years ago

Thank you @octogonz!

Wonder if that file name was changed in a recent version of Docusaurus...

damageboy commented 2 years ago

Will test and report