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
63 stars 15 forks source link

Not working after the latest docusaurus update #5

Closed thgossler closed 2 years ago

thgossler commented 2 years ago

Description

After installing the latest docusaurus update an error is happening during dev server startup.

Steps to reproduce

  1. Install typesense with the latest docusaurus beta version as explained here: https://docusaurus.io/docs/search#using-typesense-docsearch

Expected Behavior

Dev server is starting without errors as before the update to docusaurus version 2.0.0-beta.13.

Actual Behavior

The following error message is displayed when starting the dev server: Module not found: Error: Can't resolve '@theme/hooks/useContextualSearchFilters' in 'C:\Dev\swg\node_modules\docusaurus-theme-search-typesense\src\theme\hooks' client (webpack 5.64.2) compiled with 1 error

Metadata

Typsense Version:

docusaurus-theme-search-typesense@0.1.0 | MIT | deps: 11 | versions: 5 Typesense search component for Docusaurus. https://github.com/typesense/docusaurus-theme-search-typesense#readme

dist .tarball: https://registry.npmjs.org/docusaurus-theme-search-typesense/-/docusaurus-theme-search-typesense-0.1.0.tgz .shasum: 355afa3fd9407074a1e6e12d4dd385a214ba358d .integrity: sha512-agdbDigezghgkTjdYEfKB3CB2H0OVBoYNjm4fhPPbCiACzelSRF9dDkiuiqAU6HcgUSMx3T7p/EQD5kW1/gpHQ== .unpackedSize: 52.8 kB

dependencies: @docusaurus/core: 2.0.0-beta.4 @docusaurus/utils: 2.0.0-beta.4 eta: ^1.12.1 typesense-instantsearch-adapter: ^2.2.0-1 @docusaurus/theme-common: 2.0.0-beta.4 algoliasearch-helper: ^3.3.4 lodash: ^4.17.20 typesense: ^0.14.0 @docusaurus/utils-validation: 2.0.0-beta.4 clsx: ^1.1.1 typesense-docsearch-react: ^0.0.1

NPM version: npm: '8.1.2', node: '16.13.1'

OS: Windows 10 Enterprise 21H1 latest

PatrickH39 commented 2 years ago

I'm getting the same issue!

tbrockman commented 2 years ago

Haven't tested e2e, but I created a fork and changed the import to:

// import useContextualSearchFilters from '@theme/hooks/useContextualSearchFilters';
import { useContextualSearchFilters } from '@docusaurus/theme-common';

and updated @docusaurus dependencies to latest (2.0.0-beta.4 -> 2.0.0-beta.14) as peer dependencies, i.e:

    "peerDependencies": {
        "@docusaurus/core": "2.0.0-beta.14",
        "@docusaurus/theme-common": "2.0.0-beta.14",
        "@docusaurus/utils": "2.0.0-beta.14",
        "@docusaurus/utils-validation": "2.0.0-beta.14",
                 "...other peer deps"
    },

Prevents the compilation error, but haven't verified if this causes any runtime issues.

jasonbosco commented 2 years ago

Thanks @tbrockman. I've pushed that out as an update in v0.2.0-0. Could you give it a try to see if it works?

tbrockman commented 2 years ago

Yep, seems to compile, thanks for the quick turn-around!

damageboy commented 2 years ago

Is there a reason not to merge this into master and release 0.2.0?

jasonbosco commented 2 years ago

Thank you for confirming. Just published 0.2.0 with this fix.

damageboy commented 2 years ago

Thanks!

thgossler commented 2 years ago

After updating the server and the plugin to 0.2.0 / 0.2.1 I'm getting an error now in client side search regarding "docusaurus_tag" in filter_by query header which contains "docusaurus_tag:=[default,docs-default-current]". The server complains in the logs that this cannot be handled.

Does anybody else also have this problem?

jasonbosco commented 2 years ago

Could you try doing a docker pull on the scraper image and then running the scraper again, to see if that fixes the issue?

If that doesn’t fix the issue, could look at the network requests in the browser, find the last network request to Typesense, copy-as-curl the request and paste it here?

thgossler commented 2 years ago

I'm always pulling the latest version of the Docker image in the pipeline like

docker run --net=host --env-file=.env -e "CONFIG=$(cat docsearch.config.json | jq -r tostring)" typesense/docsearch-scraper

Now I have rolled-back to docusaurus beta.9 and docusaurus-theme-search-typesense 0.1.0 and the search is working again with typesense server version 0.22.1.

I will perform a clean upgrade to docusaurus beta.14 and docusaurus-theme-search-typesense 0.2.1 again and then send the server logs and the curl request leading to the error.

jasonbosco commented 2 years ago

Actually could you try with v0.3.0-1 of docusaurus-theme-search-typesense? That has an additional fix.