Docusaurs plugin fails to start when Blog disabled
Phil-Sime opened this issue · comments
Describe the bug
When I attempt to start my Docusaurus site with a configuration that has blogs disabled the Orama Docusarus plugin throws an error.
The config file docusaurus.config.js
contains this line to disable the blog functionality
blog: false,
This is the error I receive
[ERROR] TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at /Users/user-redacted/Dev/github/GitHub/repo-redacted/node_modules/@orama/plugin-docusaurus-v3/lib/index.js:73:43
at Array.forEach (<anonymous>)
at Object.allContentLoaded (/Users/user-redacted/Dev/github/GitHub/repo-redacted/node_modules/@orama/plugin-docusaurus-v3/lib/index.js:52:24)
at /Users/user-redacted/Dev/github/GitHub/repo-redacted/node_modules/@docusaurus/core/lib/server/plugins/plugins.js:91:22
at async /Users/user-redacted/Dev/github/GitHub/repo-redacted/node_modules/@docusaurus/core/lib/server/plugins/plugins.js:108:76
at async Promise.all (index 4)
at async /Users/user-redacted/Dev/github/GitHub/repo-redacted/node_modules/@docusaurus/core/lib/server/plugins/plugins.js:106:9
at async /Users/user-redacted/Dev/github/GitHub/repo-redacted/node_modules/@docusaurus/core/lib/server/plugins/plugins.js:146:40
at async loadSite (/Users/user-redacted/Dev/github/GitHub/repo-redacted/node_modules/@docusaurus/core/lib/server/site.js:127:45)
at async createReloadableSite (/Users/user-redacted/Dev/github/GitHub/repo-redacted/node_modules/@docusaurus/core/lib/commands/start/utils.js:46:16)
at async Command.start (/Users/user-redacted/Dev/github/GitHub/repo-redacted/node_modules/@docusaurus/core/lib/commands/start/start.js:22:28)
If I enable blog with this line it works
blog: { }, // Blog needs to be enabled for search to work
To Reproduce
- Install Docusaurus
- Disable the blog via the Docusaurus config
blog: false
- Install DOcusaurus Orama plugin
- Start site
Expected behavior
I expect the plugin to skip the blog feature if it is disabled.
Environment Info
OS: MacOS 14.4.1
Docusaurus version: v3.2.1
Node version: v21.7.3
Affected areas
Search
Additional context
Remove these lines from node_modules/@orama/plugin-docusaurus-v3/lib/index.js
"fixes" the issue in my case as I don't use blog functionality.
case "blogs":
const blogsInstances = Object.keys(value);
blogsInstances.forEach(async (instance) => {
const loadedInstance = value[instance];
allOramaDocsPromises.push(...loadedInstance.blogPosts.map(({ metadata }) => generateDocs({
siteDir: ctx.siteDir,
version: "current",
category: "blogs",
data: metadata
})));
});
break;
Hi @Phil-Sime! Since you identified the issue already, would you be up for sending a PR? :)