Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nikolaymatrosov opened this issue Feb 23, 2024 · 2 comments · Fixed by #719
Closed

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

nikolaymatrosov opened this issue Feb 23, 2024 · 2 comments · Fixed by #719

Comments

@nikolaymatrosov
Copy link

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

@micheleriva
Copy link
Member

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

@SaraVieira
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants