askorama / orama

🌌 Fast, dependency-free, full-text and vector search engine with typo tolerance, filters, facets, stemming, and more. Works with any JavaScript runtime, browser, server, service!

Home Page:https://docs.askorama.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

plugin-docusaurus-v3 does not work when Docusaurus in blog only mode

nikolaymatrosov opened this issue · comments

Describe the bug

Plugin crashes when Docusaurus in blog only mode.

To Reproduce

  1. install Docusaurus
npx create-docusaurus@latest orama-docusaurus classic --typescript
  1. add Orama plugin
npm i --save @orama/plugin-docusaurus-v3
  1. Delete the existing homepage at ./src/pages/index.js
  2. Modify docusaurus.config.ts to switch to blog only mode and enable the plugin
@@ -33,14 +33,9 @@
         [
             'classic',
             {
-                docs: {
-                    sidebarPath: './sidebars.ts',
-                    // Please change this to your repo.
-                    // Remove this to remove the "edit this page" links.
-                    editUrl:
-                        'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
-                },
+                docs: false,
                 blog: {
+                    routeBasePath: '/',
                     showReadingTime: true,
                     // Please change this to your repo.
                     // Remove this to remove the "edit this page" links.
@@ -53,6 +48,9 @@
             } satisfies Preset.Options,
         ],
     ],
+    plugins: [
+        "@orama/plugin-docusaurus-v3",
+    ],
     themeConfig: {
         // Replace with your project's social card
         image: 'img/docusaurus-social-card.jpg',
@@ -63,62 +61,11 @@
                 src: 'img/logo.svg',
             },
             items: [
-                {
-                    type: 'docSidebar',
-                    sidebarId: 'tutorialSidebar',
-                    position: 'left',
-                    label: 'Tutorial',
-                },
-                { to: '/blog', label: 'Blog', position: 'left' },
-                {
-                    href: 'https://github.com/facebook/docusaurus',
-                    label: 'GitHub',
-                    position: 'right',
-                },
             ],
         },
         footer: {
             style: 'dark',
             links: [
-                {
-                    title: 'Docs',
-                    items: [
-                        {
-                            label: 'Tutorial',
-                            to: '/docs/intro',
-                        },
-                    ],
-                },
-                {
-                    title: 'Community',
-                    items: [
-                        {
-                            label: 'Stack Overflow',
-                            href: 'https://stackoverflow.com/questions/tagged/docusaurus',
-                        },
-                        {
-                            label: 'Discord',
-                            href: 'https://discordapp.com/invite/docusaurus',
-                        },
-                        {
-                            label: 'Twitter',
-                            href: 'https://twitter.com/docusaurus',
-                        },
-                    ],
-                },
-                {
-                    title: 'More',
-                    items: [
-                        {
-                            label: 'Blog',
-                            to: '/blog',
-                        },
-                        {
-                            label: 'GitHub',
-                            href: 'https://github.com/facebook/docusaurus',
-                        },
-                    ],
-                },
             ],
             copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`,
         },

And you will get this error:

~/.nvm/versions/node/v20.10.0/bin/npm run start

> orama-docusaurus@0.0.0 start
> docusaurus start

[INFO] Starting the development server...

TypeError: Cannot read properties of undefined (reading 'map')
    at Object.contentLoaded (~/Documents/experiment/orama-docusaurus/node_modules/@orama/plugin-docusaurus-v3/lib/index.js:34:39)
    at ~/Documents/experiment/orama-docusaurus/node_modules/@docusaurus/core/lib/server/plugins/index.js:99:22
    at async Promise.all (index 4)
    at async loadPlugins (~/Documents/experiment/orama-docusaurus/node_modules/@docusaurus/core/lib/server/plugins/index.js:63:5)
    at async load (~/Documents/experiment/orama-docusaurus/node_modules/@docusaurus/core/lib/server/index.js:76:58)
    at async Command.start (~/Documents/experiment/orama-docusaurus/node_modules/@docusaurus/core/lib/commands/start.js:44:19)

[INFO] Docusaurus version: 3.1.1
Node version: v20.10.0

Process finished with exit code 1

Full repo here https://github.com/nikolaymatrosov/orama-docusaurus

Expected behavior

I expect I can search in my blog posts

Environment Info

Node: 20.10
Docusaurus: 3.1.1
Orama: 2.0.8

Affected areas

Initialization, Search

Additional context

No response

@nikolaymatrosov thank you so much for catching this. We'll definitely fix it

Hey!

Thank you so much for the detailed way to get this issue! Made it super easy to reproduce, I fixed it today and it will be in the next version