cmfcmf / docusaurus-search-local

Offline / Local Search for Docusaurus v2. Try it live at:
https://cmfcmf.github.io/OpenWeatherMap-PHP-API/
MIT License
438 stars 67 forks source link

Bad Docusaurus plugin value as path #94

Closed vinch closed 2 years ago

vinch commented 2 years ago

Hello,

I have a problem but I'm not sure if it's an issue with Docusaurus or with this plugin.

I recently disabled the blog feature of Docusaurus so I told docusaurus-search-local to stop indexing the blog by doing this:

plugins: [
  require.resolve("@cmfcmf/docusaurus-search-local"),
  { indexBlog: false },
],

Unfortunately, when I'm doing that, I get the following error from Docusaurus:

[INFO] The validation system was added recently to Docusaurus as an attempt to avoid user configuration errors.
We may have made some mistakes.
If you think your configuration is valid and should keep working, please open a bug report.
[ERROR] Error:  => Bad Docusaurus plugin value as path [plugins,1].
Example valid plugin config:
{
  plugins: [
    ["@docusaurus/plugin-content-docs",options],
    "./myPlugin",
    ["./myPlugin",{someOption: 42}],
    function myPlugin() { },
    [function myPlugin() { },options]
  ],
};

    at validateConfig (/Users/vinch/Sites/ludus/help/node_modules/@docusaurus/core/lib/server/configValidation.js:167:15)
    at loadConfig (/Users/vinch/Sites/ludus/help/node_modules/@docusaurus/core/lib/server/config.js:18:50)
    at loadSiteConfig (/Users/vinch/Sites/ludus/help/node_modules/@docusaurus/core/lib/server/index.js:34:51)
    at loadContext (/Users/vinch/Sites/ludus/help/node_modules/@docusaurus/core/lib/server/index.js:44:69)
    at load (/Users/vinch/Sites/ludus/help/node_modules/@docusaurus/core/lib/server/index.js:203:27)
    at loadSite (/Users/vinch/Sites/ludus/help/node_modules/@docusaurus/core/lib/commands/start.js:32:34)
    at FSWatcher.<anonymous> (/Users/vinch/Sites/ludus/help/node_modules/@docusaurus/core/lib/commands/start.js:52:9)
    at invokeFunc (/Users/vinch/Sites/ludus/help/node_modules/lodash/lodash.js:10401:23)
    at trailingEdge (/Users/vinch/Sites/ludus/help/node_modules/lodash/lodash.js:10450:18)
    at Timeout.timerExpired [as _onTimeout] (/Users/vinch/Sites/ludus/help/node_modules/lodash/lodash.js:10438:18)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)

I tried doing this below, but it doesn't work either.

plugins: [
  "@cmfcmf/docusaurus-search-local",
  { indexBlog: false },
],

As they're admitting themselves that they could have made mistakes, I'm wondering if I should file a bug with them or if it's a problem with this plugin. Another possibility (a likely one) would be me being stupid and missing something obvious so let me know if it's the case :)

Important: I'm running @docusaurus/core version ^2.0.0-beta.14 and @cmfcmf/docusaurus-search-local version ^0.9.4.

Thank you!

cmfcmf commented 2 years ago

Hi, I think you are missing an array. You currently have a plugins array with two elements: the plugin and its option. However, you need to have a plugins array with one nested array, that contains two elements: the plugin and its options. This should work:

plugins: [
  [
    require.resolve("@cmfcmf/docusaurus-search-local"),
    { indexBlog: false },
  ]
],
vinch commented 2 years ago

Indeed, that's it. Thanks, @cmfcmf!