easyops-cn / docusaurus-search-local

Offline/local search for Docusaurus v2/v3
https://easyops-cn.github.io/docusaurus-search-local/
MIT License
712 stars 90 forks source link

Allow no defalut doc id #392

Closed tisonkun closed 10 months ago

tisonkun commented 10 months ago
ERROR
Docusaurus plugin global data not found for "docusaurus-plugin-content-docs" plugin with id "default".
    at usePluginData (webpack-internal:///./node_modules/.pnpm/@docusaurus+core@3.0.1_@docusaurus+types@3.0.1_debug@4.3.4_react-dom@18.2.0_react@18.2.0_typescript@5.2.2/node_modules/@docusaurus/core/lib/client/exports/useGlobalData.js:14:712)
    at useDocsData (webpack-internal:///./node_modules/.pnpm/@docusaurus+plugin-content-docs@3.0.1_debug@4.3.4_react-dom@18.2.0_react@18.2.0_typescript@5.2.2/node_modules/@docusaurus/plugin-content-docs/lib/client/index.js:25:264)
    at useDocsPreferredVersion (webpack-internal:///./node_modules/.pnpm/@docusaurus+theme-common@3.0.1_@docusaurus+types@3.0.1_react-dom@18.2.0_react@18.2.0_typescript@5.2.2/node_modules/@docusaurus/theme-common/lib/contexts/docsPreferredVersion.js:42:214)
    at SearchBar (webpack-internal:///./node_modules/.pnpm/@easyops-cn+docusaurus-search-local@0.40.1_@docusaurus+theme-common@3.0.1_@docusaurus+types@3_iw6cbjy5bcq7mtwfcsy47ex4hu/node_modules/@easyops-cn/docusaurus-search-local/dist/client/client/theme/SearchBar/SearchBar.jsx:35:107)
    at renderWithHooks (webpack-internal:///./node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom.development.js:16305:18)
    at mountIndeterminateComponent (webpack-internal:///./node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom.development.js:20069:13)
    at beginWork (webpack-internal:///./node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom.development.js:21582:16)
    at HTMLUnknownElement.callCallback (webpack-internal:///./node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom.development.js:4164:14)
    at Object.invokeGuardedCallbackDev (webpack-internal:///./node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom.development.js:4213:16)
    at invokeGuardedCallback (webpack-internal:///./node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom.development.js:4277:31)

I use docs without the default ID. It'd better to tolerate with this config.

tisonkun commented 10 months ago

I temporarily add a dummy default doc plugin instance:

https://github.com/tisonspieces/www-site/blob/3529f8ce3ad864ff234c8b5ec3238c823cce2179/docusaurus.config.ts#L17-L19

weareoutman commented 10 months ago

Currently you have to set docsPluginIdForPreferredVersion

image
tisonkun commented 10 months ago

Thank you!

tisonkun commented 10 months ago

@weareoutman may I ask what "preferred version" means? I don't know what's the effect I set this property ..

weareoutman commented 10 months ago

It has no other effect if you don't have multi-versioned docs