easyops-cn / docusaurus-search-local

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

Search bar doesn't appear #114

Open Skipper0707 opened 3 years ago

Skipper0707 commented 3 years ago

Hello I've followed through the installation guide but, the search bar does not appear after the build as if the plugin's not working, I'm sure there's some misconfiguration on my part but, troubleshooting has been proving fruitless so far. I'd be delighted if I'd get any help figuring this out.

Report: I entered the npm install --save @easyops-cn/docusaurus-search-local in my project directory and then added the plugin in the docusaurus.config.js as below:

There are no errors, everything seems fine but the search bar doesn't appear

const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula");

/** @type {import('@docusaurus/types').DocusaurusConfig} */
module.exports = {
  plugins: [
     [require.resolve("@easyops-cn/docusaurus-search-local"),
             {hashed: true}
     ],
  ],

  title: "TITLE",
  tagline: "TAGLINE",
  url: "https://your-docusaurus-test-site.com",
  baseUrl: "/",
  onBrokenLinks: "warn",
  onBrokenMarkdownLinks: "warn",
  favicon: "IMG",
  organizationName: "facebook", // Usually your GitHub org/user name.
  projectName: "docusaurus", // Usually your repo name.
  themeConfig: {
    navbar: {
      title: "TITLE",
      logo: {
        alt: "TITLE",
        src: "IMG"
      },
      items: [
        {
          type: "doc",
          docId: "Home",
          position: "left",
          label: "Documents"
        },
      ]
    },
    footer: {
      style: "dark",
      links: [
        {
          title: "Docs",
          items: [
            {
              label: "Home",
              to: "/docs/Home"
            },

          ]
        },
        ],
       },
    prism: {
      theme: lightCodeTheme,
      darkTheme: darkCodeTheme
    }
  },
  presets: [
    [
      "@docusaurus/preset-classic",
      {
        docs: {
          sidebarPath: require.resolve("./sidebars.js"),
          // Please change this to your repo.
          editUrl: "https://github.com/facebook/docusaurus/edit/master/website/"
        },
        blog: {
          showReadingTime: true,
          // Please change this to your repo.
          editUrl:
            "https://github.com/facebook/docusaurus/edit/master/website/blog/"
        },
        theme: {
          customCss: require.resolve("./src/css/custom.css")
        }
      }
    ]
  ]
};

I copied the whole config file in case it'd help figure this out.

Many thanks in advance.

reutenkoivan commented 2 years ago

https://github.com/facebook/docusaurus/issues/6488 But in your case you can try configure plugins after presets

noraj commented 2 years ago

@easyops-cn/docusaurus-search-local should be loaded in themes and not in plugins also you are missing this navbar item:

        {
          type: 'search',
          position: 'right',
        },