GithubHelp home page GithubHelp logo

cmfcmf / docusaurus-search-local Goto Github PK

View Code? Open in Web Editor NEW
433.0 7.0 67.0 12.44 MB

Offline / Local Search for Docusaurus v2. Try it live at:

Home Page: https://cmfcmf.github.io/OpenWeatherMap-PHP-API/

License: MIT License

JavaScript 72.68% CSS 0.89% Shell 0.53% TypeScript 25.90%
docusaurus lunrjs search plugin

docusaurus-search-local's Introduction

Offline / Local Search for Docusaurus v2+

Version License code style: prettier GitHub issues GitHub last commit

Offline / local search for Docusaurus v2+ that works behind your firewall.

Feature Highlights:

  • Supports multiple documentation versions
  • Supports documentation written in languages other than English
  • Highlights search results
  • Customized parsers for docs, blogs, and general pages
  • Lazy-loads the index

Search in Action

Note: We use the open source algolia/autocomplete library for the searchbox. This library is just used as the frontend, and, unlike the default Docusaurus search experience (algolia/docsearch), does not connect to any Algolia or third-party servers.

Installation

npm install @cmfcmf/docusaurus-search-local

or

yarn add @cmfcmf/docusaurus-search-local

Usage

Add this plugin to the plugins array in docusaurus.config.js.

module.exports = {
  // ...
  plugins: [require.resolve("@cmfcmf/docusaurus-search-local")],

  // or, if you want to specify options:

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

The following options are available (defaults are shown below):

{
  // whether to index docs pages
  indexDocs: true,

  // Whether to also index the titles of the parent categories in the sidebar of a doc page.
  // 0 disables this feature.
  // 1 indexes the direct parent category in the sidebar of a doc page
  // 2 indexes up to two nested parent categories of a doc page
  // 3...
  //
  // Do _not_ use Infinity, the value must be a JSON-serializable integer.
  indexDocSidebarParentCategories: 0,

  // Includes parent categories path in search result
  includeParentCategoriesInPageTitle: false,

  // whether to index blog pages
  indexBlog: true,

  // whether to index static pages
  // /404.html is never indexed
  indexPages: false,

  // language of your documentation, see next section
  language: "en",

  // setting this to "none" will prevent the default CSS to be included. The default CSS
  // comes from autocomplete-theme-classic, which you can read more about here:
  // https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-theme-classic/
  // When you want to overwrite CSS variables defined by the default theme, make sure to suffix your
  // overwrites with `!important`, because they might otherwise not be applied as expected. See the
  // following comment for more information: https://github.com/cmfcmf/docusaurus-search-local/issues/107#issuecomment-1119831938.
  style: undefined,

  // The maximum number of search results shown to the user. This does _not_ affect performance of
  // searches, but simply does not display additional search results that have been found.
  maxSearchResults: 8,

  // lunr.js-specific settings
  lunr: {
    // When indexing your documents, their content is split into "tokens".
    // Text entered into the search box is also tokenized.
    // This setting configures the separator used to determine where to split the text into tokens.
    // By default, it splits the text at whitespace and dashes.
    //
    // Note: Does not work for "ja" and "th" languages, since these use a different tokenizer.
    tokenizerSeparator: /[\s\-]+/,
    // https://lunrjs.com/guides/customising.html#similarity-tuning
    //
    // This parameter controls the importance given to the length of a document and its fields. This
    // value must be between 0 and 1, and by default it has a value of 0.75. Reducing this value
    // reduces the effect of different length documents on a term’s importance to that document.
    b: 0.75,
    // This controls how quickly the boost given by a common word reaches saturation. Increasing it
    // will slow down the rate of saturation and lower values result in quicker saturation. The
    // default value is 1.2. If the collection of documents being indexed have high occurrences
    // of words that are not covered by a stop word filter, these words can quickly dominate any
    // similarity calculation. In these cases, this value can be reduced to get more balanced results.
    k1: 1.2,
    // By default, we rank pages where the search term appears in the title higher than pages where
    // the search term appears in just the text. This is done by "boosting" title matches with a
    // higher value than content matches. The concrete boosting behavior can be controlled by changing
    // the following settings.
    titleBoost: 5,
    contentBoost: 1,
    tagsBoost: 3,
    parentCategoriesBoost: 2, // Only used when indexDocSidebarParentCategories > 0
  }
}

You can now use the search bar to search your documentation.

Important: Search only works for the statically built documentation (i.e., after you ran npm run docusaurus build in your documentation folder).

Search does not work in development (i.e., when running npm run docusaurus start). If you want to test search locally, first build the documentation with npm run docusaurus build, and then serve it via npm run docusaurus serve.

Non-English Documentation

Use the language option if your documentation is not written in English. You can either specify a single language or an array of multiple languages. The following languages are available:

ar, da, de, en, es, fi, fr, hi, hu, it, ja, nl, no, pt, ro, ru, sv, th, tr, vi, zh

Important: For Chinese language support (zh), you also have to install the nodejieba npm package at ^2.5.0.

Documentation Versions

Documentation versions created with the official Docusaurus docs plugin are supported. The search bar defaults to the latest version (not next, but the latest version defined in versions.json) when not on a documentation page (e.g., when looking at a blog post or a static page). If the user visits a documentation page, the version is extracted from the page and search will only search the documentation of that version. The searchbar placeholder text always reflects the currently detected documentation version.

Internationalization

This plugin supports documentation using Docusaurus i18n out of the box.. Please contribute additional translations by creating a new translation file in the codeTranslations subfolder and submitting a PR.

You can also adjust translations by modifiying the translations in <yourfolder>/i18n/<locale>/code.json that start with cmfcmf/d-s-l.. Read more at: https://docusaurus.io/docs/i18n/tutorial#translate-json-files

Debugging

If building your documentation produces an error, you can build it in debug mode to figure out which page is causing it. To do so, simply set the DEBUG environment variable when building your documentation: DEBUG=1 npm run docusaurus build.

CONTRIBUTING

Please see the CONTRIBUTING.md file for further information.

License

MIT

docusaurus-search-local's People

Contributors

aonpongsiri avatar ardavank avatar arnaud4d avatar audio avatar birjj avatar celizi avatar cmfcmf avatar daniloab avatar dependabot[bot] avatar duanwilliam avatar ekangal avatar emanuelemason avatar fashxp avatar fpavkovcek avatar glimmaren avatar gupta-anubhav12 avatar jafin avatar josh-cena avatar jules-viktor avatar kamelon7 avatar keyel avatar kleinschmidtj avatar loque avatar oleh-hutsalo-ks avatar outbreak avatar peteryang1756 avatar piilu avatar sisp avatar sivaraam avatar zeecapp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

docusaurus-search-local's Issues

Issues with Highlighting - How to stop the Highlighting?

Hello and thanks for the excellent plugin.

One nice feature of this plugin is that after searching for something and clicking on a result, the search term is helpfully highlighted in yellow across the entire page.

Example (which is cropped a bit):

image

While highlighting is probably helpful by default, in some cases it won't be helpful, because the search term is so common. For example, in the above screenshot, the page is now difficult to read because of all of the yellow spam/noise. Thus, after seeing this, users will attempt to find a way to un-highlight the words:

  1. Their first assumption would be to try deleting the search term in the top-right-hand-corner. Handily, there is an blue X there. Unfortunately, clicking on that does delete the search term, but does not delete the highlighting.

  2. Their second assumption will be to refresh the page, but even that does not remove the highlighting. (Because it is baked into the URL.)

  3. Finally, users will resort to manually navigating away from the page, and then manually navigating back. This will finally result in the highlighting being removed. (Alternatively, if they happen to notice the "highlight" query parameter, they could manually remove that, and then refresh the page, but this is even more cumbersome.)

In conclusion, this is a frustrating user experience. I propose that when the blue X is clicked, it also removes the highlighting.

No search index after running 'yarn build'

When I run yarn build then yarn start and try to search something I see:

"The search index is only available when you run docusaurus build!"

I see in the Readme that search does not work in development, is that why I see this error?

Module not found: Can't resolve '@theme/hooks/useDocs'

Bug description

An error occurred: Module not found: Can't resolve '@theme/hooks/useDocs' after running yarn build.

Reproduction

  • yarn add @cmfcmf/docusaurus-search-local
  • add plugin settings to docusaurus.config.js
  • yarn build

Environment

Package Versions

yarn list v1.21.1
β”œβ”€ @cmfcmf/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
└─ @docusaurus/[email protected]

Node Version

v12.14.0

Docusaurus Environment

  • Are you using a custom theme?: No
  • Paste the plugin config of the local search plugin from your docusaurus.config.js file
  plugins: [
    [require.resolve("@cmfcmf/docusaurus-search-local") ]],

Additional Information

There seems to be no file like "hooks/useDocs.js" in this repository.
Is the required file external one?

Chineses language not suport

hi! i found lunr-language is support chinese now, i install the depend module nodejieba to support it. and setting languages: ['en', 'zh']; in config file. building is OK.

But it doesn’t seem to be running very well, what should i do?

thanks.

Unmark highlighting using keyboard

πŸ¦„
Hello, first of all - great plugin, really easy to setup and use!
What is my only concern - is there a way to cancel highlighting marks when you are already got to the needed page? It can be annoying, especially when you type in your search only one letter and already getting the results you are looking for, but after you go to the page you're looking for, it highlights every word with the letter you searched for.
It just would be nice to unmark all highlighted results for this page on for example an ESC key using keyboard.
I can even make a pull request with this feature if needed.

Bad Docusaurus plugin value as path

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!

Tag pages or folders to be excluded from search index?

Hello, I could not find any feature to tag certain pages or folders to be excluded from the search features. As we are building out our docusaurus pages, some teams have work in progress, and as we publish releases sometimes those are not yet linked into the navigation because they're not ready, but the index still picks them up. Is there any feature for this, or is this a reasonable feature that might be useful to include?

Search only working for Next, no results for versioned documents

Bug description

I'm only getting search results when I navigate to /next. When using search for other versions (including latest), I do not see any search results. This is despite search-index.json seemingly indexing all versions correctly.

Reproduction

Docusaurus configuration here
Build output here
Site at https://beehive-innovation.github.io/rain-protocol/

Environment

Package Versions

[email protected] /home/marcus/rain-protocol/docusaurus
β”œβ”€β”€ @cmfcmf/[email protected] 
β”œβ”€β”€ @docusaurus/[email protected] 
└─┬ @docusaurus/[email protected]
  β”œβ”€β”€ @docusaurus/[email protected]  deduped
  β”œβ”€β”¬ @docusaurus/[email protected]
  β”‚ β”œβ”€β”€ @docusaurus/[email protected]  deduped
  β”‚ └─┬ @docusaurus/[email protected]
  β”‚   └── @docusaurus/[email protected]  deduped
  β”œβ”€β”¬ @docusaurus/[email protected]
  β”‚ └── @docusaurus/[email protected]  deduped
  β”œβ”€β”¬ @docusaurus/[email protected]
  β”‚ └── @docusaurus/[email protected]  deduped
  β”œβ”€β”¬ @docusaurus/[email protected]
  β”‚ └── @docusaurus/[email protected]  deduped
  β”œβ”€β”¬ @docusaurus/[email protected]
  β”‚ └── @docusaurus/[email protected]  deduped
  β”œβ”€β”¬ @docusaurus/[email protected]
  β”‚ └── @docusaurus/[email protected]  deduped
  β”œβ”€β”¬ @docusaurus/[email protected]
  β”‚ └── @docusaurus/[email protected]  deduped
  β”œβ”€β”¬ @docusaurus/[email protected]
  β”‚ β”œβ”€β”€ @docusaurus/[email protected]  deduped
  β”‚ └─┬ @docusaurus/[email protected]
  β”‚   └── @docusaurus/[email protected]  deduped
  └─┬ @docusaurus/[email protected]
    └── @docusaurus/[email protected]  deduped

Node Version

v14.18.0

Docusaurus Environment

  • Are you using a custom theme?
    No
  • Paste the plugin config of the local search plugin from your docusaurus.config.js file
plugins: [
    [
      require.resolve("@cmfcmf/docusaurus-search-local"),
      {
        docsRouteBasePath: "/",
      },
    ],
  ],

Additional context

Working docs/ folder is placed a level above docusaurus/ folder, which is not typical.
I am also in docs-only mode.

I noticed this Skipping search index generation message when building, but it seems to happily index everything correctly after.

[en] Creating an optimized production build...
[Local Search] [INFO]: Skipping search index generation for documentation because directory /home/marcus/rain-protocol/docusaurus/docs does not exist.

βœ” Client
  

βœ” Server
  Compiled successfully in 6.70s


βœ” Client
  

● Server β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ cache (99%) shutdown IdleFileCachePlugin
 stored

[Local Search] [INFO]: Gathering documents
[Local Search] [INFO]: Parsing documents
[Local Search] [INFO]: Building index
[Local Search] [INFO]: Writing index to disk
[Local Search] [INFO]: Index written to disk, success!
Success! Generated static files in "build".

Use `npm run serve` command to test your build locally.

Find a way to pass the names of indexes that exist from the server to the client

Follow-up of #85.

try {
const response = await fetch(`${baseUrl}search-index-${tag}.json`);
if (!response.ok) return EMPTY_INDEX;
json = await response.json();
} catch (err) {
// An index might not actually exist if no pages for it have been indexed.
// https://github.com/cmfcmf/docusaurus-search-local/issues/85
// TODO: we should somehow pass the names of indexes that exist to the
// client at build time instead of catching the error here.
return EMPTY_INDEX;
}

Unable to resolve dependency tree

Bug description

Hello, Team!
I try installation but have error: Unable to resolve dependency tree.

Reproduction

Run: npm install @cmfcmf/docusaurus-search-local

Environment

Output:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @docusaurus/[email protected]
npm ERR! node_modules/@docusaurus/core
npm ERR! @docusaurus/core@"2.0.0-beta.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @docusaurus/core@"^2.0.0" from @cmfcmf/[email protected]
npm ERR! node_modules/@cmfcmf/docusaurus-search-local
npm ERR! @cmfcmf/docusaurus-search-local@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/..../.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/.../.npm/_logs/2021-05-13T09_10_02_560Z-debug.log

Package Versions

[email protected] /home/..../docusaurus
β”œβ”€β”€ @docusaurus/[email protected]
└─┬ @docusaurus/[email protected]
β”œβ”€β”€ @docusaurus/[email protected] deduped
β”œβ”€β”¬ @docusaurus/[email protected]
β”‚ β”œβ”€β”€ @docusaurus/[email protected] deduped
β”‚ └─┬ @docusaurus/[email protected]
β”‚ └── @docusaurus/[email protected] deduped
β”œβ”€β”¬ @docusaurus/[email protected]
β”‚ └── @docusaurus/[email protected] deduped
β”œβ”€β”¬ @docusaurus/[email protected]
β”‚ └── @docusaurus/[email protected] deduped
β”œβ”€β”¬ @docusaurus/[email protected]
β”‚ └── @docusaurus/[email protected] deduped
β”œβ”€β”¬ @docusaurus/[email protected]
β”‚ └── @docusaurus/[email protected] deduped
β”œβ”€β”¬ @docusaurus/[email protected]
β”‚ └── @docusaurus/[email protected] deduped
β”œβ”€β”¬ @docusaurus/[email protected]
β”‚ └── @docusaurus/[email protected] deduped
β”œβ”€β”¬ @docusaurus/[email protected]
β”‚ β”œβ”€β”€ @docusaurus/[email protected] deduped
β”‚ └─┬ @docusaurus/[email protected]
β”‚ └── @docusaurus/[email protected] deduped
└─┬ @docusaurus/[email protected]
└── @docusaurus/[email protected] deduped

Node Version

node -v
v16.1.0
npm -v
7.11.2

Docusaurus Environment

  • Are you using a custom theme? NO
  • Paste the plugin config of the local search plugin from your docusaurus.config.js file
    docusaurus.config.js.txt

Additional context

Parsing documents Error: This should not be reached (debug: got type style)

Bug description

I get this error while bulding:

βœ” Server
  Compiled successfully in 42.82s

[Local Search] [INFO]: Gathering documents
[Local Search] [INFO]: Parsing documents
Error: This should not be reached (debug: got type style)

Environment

Package Versions

yarn list v1.17.3
β”œβ”€ @cmfcmf/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
└─ @docusaurus/[email protected]

Node Version

v11.15.0

Docusaurus Environment

  • Are you using a custom theme? No
plugins: [
    path.resolve(__dirname, 'plugins/custom-webpack-plugin'),
    '@docusaurus/plugin-ideal-image',
    ['@cmfcmf/docusaurus-search-local', {
      indexBlog: false
    }]
  ],

Additional context

I've just installed and configured the plugin.

Indexing in different languages

Good afternoon!

I wanted to index the document in Russian:

#package.json
...
  "dependencies": {
...
    "lunr-languages": "^1.4.0"
  },
...

-In the source code, index.js added the following:

var lunr = require("lunr");
require('lunr-languages/lunr.stemmer.support')(lunr);
require('lunr-languages/lunr.ru')(lunr);
require('lunr-languages/lunr.multi')(lunr);
...
      const index = lunr(function () {
        this.use(lunr.multiLanguage('en', 'ru'));
        this.ref("id");
        this.field("title");
        this.field("content");
...
  • yarn build
  • copy build directory to nginx
  • open in browser
  • enter some text in search bar

result:

Uncaught (in promise) Error: Cannot load unregistered function: stemmer-ru
    at 2.6c5301c6.js:2
    at Array.forEach (<anonymous>)
    at Function.P.Pipeline.load (2.6c5301c6.js:2)
    at Function.P.Index.load (2.6c5301c6.js:2)
    at 2.6c5301c6.js:2
    at async Promise.all (/index 0)

i am not strong in js
can you help me?

Feature Request: Ability to control detail of index files

Currently, the index file generated is mainly based on markdown files' title and heading. I would love to add more control about this so we can also put text content to the index.

Sure, adding more info on the index file will make it bigger, that's why I hope this is configurable.

What I wish is to approximate Docusaurus.io Algolia site search. You can see that search result also contains part of the text content like this:

Screen Shot 2021-12-29 at 03 14 47

Request: Support more than one docs plugin

I am building a docs site and we have three instances of @docusaurus/plugin-content-docs. Each have their own unique ID.

Unfortuantely docusuaurus-search-local doesn't support multiple plugin-content-docs instances and enforces indexing of the default ID.

Please add support for multiple instances of plugin-content-docs.

Docusuarus V2 Fails to build when using Docusaurus Search Local

Bug description

Reproduction

Public Repo Link: https://github.com/astrawnuts/Docusaurus-NEW-Local-Search

Just to prove that docusaurus search local was the cause of the failed project build I setup a new docusaurus website using the create command for V2 Beta 13 and installed docusaurus search local. Changed the docusaurus config file and tried to build.

The following error was shown

$ DEBUG=1 yarn build
yarn run v1.22.15
warning ..\package.json: No license field
$ docusaurus build

[en] Creating an optimized production build...
Unable to build website for locale "en".
TypeError: (0 , utils_1.readDefaultCodeTranslationMessages) is not a function
    at Object.getDefaultCodeTranslationMessages (S:\Files\VS_Code\Projects\docs_v3\my-website\node_modules\@cmfcmf\docusaurus-search-local\lib\server\index.js:148:97)
    at S:\Files\VS_Code\Projects\docs_v3\my-website\node_modules\@docusaurus\core\lib\server\translations\translations.js:174:186
    at Array.map (<anonymous>)
    at getPluginsDefaultCodeTranslationMessages (S:\Files\VS_Code\Projects\docs_v3\my-website\node_modules\@docusaurus\core\lib\server\translations\translations.js:174:55)
    at load (S:\Files\VS_Code\Projects\docs_v3\my-website\node_modules\@docusaurus\core\lib\server\index.js:240:79)
    at async buildLocale (S:\Files\VS_Code\Projects\docs_v3\my-website\node_modules\@docusaurus\core\lib\commands\build.js:82:19)
    at async tryToBuildLocale (S:\Files\VS_Code\Projects\docs_v3\my-website\node_modules\@docusaurus\core\lib\commands\build.js:34:20)
    at async mapAsyncSequencial (S:\Files\VS_Code\Projects\docs_v3\my-website\node_modules\@docusaurus\utils\lib\index.js:262:24)
    at async build (S:\Files\VS_Code\Projects\docs_v3\my-website\node_modules\@docusaurus\core\lib\commands\build.js:70:25)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

If possible, provide a link to the source of your documentation or at least
the document/page this issue is about (if applicable). If this bug report is
about a failure that occurs while building your documentation, please find out
which document breaks the build process by building your documentation with debug
information enabled as described in the README (DEBUG=1 yarn build). If you can,
provide the document that breaks the build process as indicated by the debug messages.

Environment

Package Versions

If you use Yarn:
yarn list --pattern '@docusaurus|@cmfcmf' --depth=0
If you use npm:
npm list '@docusaurus/core' '@cmfcmf/docusaurus-search-local'

$  yarn list --pattern '@docusaurus|@cmfcmf' --depth=0
yarn list v1.22.15
warning ..\package.json: No license field
β”œβ”€ @cmfcmf/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
└─ @docusaurus/[email protected]
Done in 0.88s.

Node Version

node -v

$ node -v v16.13.0

Docusaurus Environment

  • Are you using a custom theme?
  • Paste the plugin config of the local search plugin from your docusaurus.config.js file

Additional context

plugin breaks on docusaurus canary from refactored theme translation api

Bug description

facebook/docusaurus#5849 refactors the theme translation api and moves
the readDefaultCodeTranslationMessages function, used in this plugin, from @docusaurus/utils into a separate package, @docusaurus/theme-translations. This should probably be updated when Docusaurus get its next stable release in 2.0.0-beta.10.

Reproduction

try yarn start on canary build (not sure which one corresponds with the breaking pr but tested on 0.0.0-4248).

Environment

Package Versions

β”œβ”€ @cmfcmf/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
└─ @docusaurus/[email protected]

Node Version

v14.15.0

Docusaurus Environment

  • using preset-classic
  • plugin config: [require.resolve('@cmfcmf/docusaurus-search-local'), {}]

Additional context

when i seted "language: ['ja']" and build ,An error has occurred related lunr

Problem

when i build project After seted docusaurus.config.js as follows

  plugins: [
    [
      require.resolve('@cmfcmf/docusaurus-search-local'),
      {
        language: ['ja'],
      },
    ],
  ],

An error has occurred related lunr

TypeError: lunr.TinySegmenter is not a constructor
   at /home/user/project/node_modules/lunr-languages/lunr.ja.js:88:21

Guess about revision

I looked around node_modules/lunr-languages/lunr.ja.js and finded tinyseg.js so Made it read it.
build is done and i could search word with japanese.

  • lunr.ja.js
require('./tinyseg.js')(lunr) // + add
var segmenter = new lunr.TinySegmenter() // γ‚€γƒ³γ‚Ήγ‚Ώγƒ³γ‚Ήη”Ÿζˆ

Sorry if my English is weird.

[Bug] Error: Can't resolve '@theme/hooks/useDocs'

Please describe the bug you are seeing

Can't build with canary using this plugin. Looks like useDocs has been replaced by @docusaurus/plugin-content-docs/client.

facebook/docusaurus#6287

How can we best reproduce the bug?

No response

Which version of Docusaurus and @cmfcmf/docusaurus-search-local are you using?

@cmfcmf/[email protected]
@docusaurus/[email protected]

Which Node.js version are you using?

v16.13.2

Which theme are you using?

Yes, I am using @docusaurus/theme-classic

How does your plugin config look like?

require.resolve("@cmfcmf/docusaurus-search-local"),
{
indexDocs: true,
indexBlog: false,
indexPages: true,
language: "en"
}

Additional context

No response

Feature Request: Please add SEO features and Search Page

Hello Sir firstly thank you for making such a great extension, So here are my feature requests

1. SEO Features

image
Just like Algolia Search can you please add support for open search it helps a lot in SEO sometimes google shows our search box directly.

2. Search Page

Can you please add search page just like https://docusaurus.io/search and one can pass parameters with url to search directly just like this https://docusaurus.io/search?q=GitHub .

Plugin not compatible with Docusaurus 2.0.0-Beta.7

Bug description

This plugin is incompatible with Docusaurus 2.0.0-Beta.7. Please see this issue. Thanks.

Reproduction

If possible, provide a link to the source of your documentation or at least
the document/page this issue is about (if applicable). If this bug report is
about a failure that occurs while building your documentation, please find out
which document breaks the build process by building your documentation with debug
information enabled as described in the README (DEBUG=1 yarn build). If you can,
provide the document that breaks the build process as indicated by the debug messages.

Environment

Package Versions

If you use Yarn:
yarn list --pattern '@docusaurus|@cmfcmf' --depth=0
If you use npm:
npm list '@docusaurus/core' '@cmfcmf/docusaurus-search-local'

Node Version

node -v

Docusaurus Environment

  • Are you using a custom theme?
  • Paste the plugin config of the local search plugin from your docusaurus.config.js file

Additional context

search icon not showing

in docusaurus.config.js
plugins: [require.resolve("@easyops-cn/docusaurus-search-local")]

in package.json

 "@cmfcmf/docusaurus-search-local": "^0.6.6",
 "@easyops-cn/docusaurus-search-local": "^0.19.1",

what else i have to add plz help

Arabic search show less information

Bug description

when I write a word in Arabic in list below search bar that show suggestion it doesn't show the text of that word I guess below image is more helpful :)

1

it just show the page that word is used but in English search it show more information.

2

Reproduction

just add ar to language support and search

[Feature Request] Search highlight

First of all: Thanks for this plugin! I really appreciate that you've written this plugin because it gives us the possibility to have a search bar in our internal docs without using Algolia. Thanks, man πŸ‘

Description

Would it be possible to add an option that allows the user to enable/ disable highlight of the search results on the (target) page?

Proposal

mark.js seems to be a good and Open Source (licensed under MIT) library that can be easily integrated into this plugin.

Allow to set search bar placeholder

It would be great to be able to customize the search bar placeholder. This would allow to display the appropriate word in other languages

Styling

How do I change the style of the search box to match my Docasaurus style?

Help/Direction editing the CSS

Hello @cmfcmf πŸ‘‹πŸ»

Love the search feature! Works great!

Not so much an issue, but a request for help/direction/instructions on how to edit/change colours of the search? I am having real trouble getting to grips with this.

docusaurus.config.js πŸ‘‡πŸ»

plugins: [
  [require.resolve('@cmfcmf/docusaurus-search-local'), {
    // whether to index docs pages
    indexDocs: true,
    // must start with "/" and correspond to the routeBasePath configured for the docs plugin
    // use "/" if you use docs-only-mode
    // (see https://v2.docusaurus.io/docs/2.0.0-alpha.70/docs-introduction#docs-only-mode)
    docsRouteBasePath: '/docs',

    // Whether to also index the titles of the parent categories in the sidebar of a doc page.
    // 0 disables this feature.
    // 1 indexes the direct parent category in the sidebar of a doc page
    // 2 indexes up to two nested parent categories of a doc page
    // 3...
    //
    // Do _not_ use Infinity, the value must be a JSON-serializable integer.
    indexDocSidebarParentCategories: 0,

    // whether to index blog pages
    indexBlog: true,
    // must start with "/" and correspond to the routeBasePath configured for the blog plugin
    // use "/" if you use blog-only-mode
    // (see https://v2.docusaurus.io/docs/2.0.0-alpha.70/blog#blog-only-mode)
    blogRouteBasePath: '/blog',

    // whether to index static pages
    // /404.html is never indexed
    indexPages: false,

    // language of your documentation, see next section
    language: "en",

    // setting this to "none" will prevent the default CSS to be included. The default CSS
    // comes from autocomplete-theme-classic, which you can read more about here:
    // https://autocomplete.algolia.com/docs/autocomplete-theme-classic
    // The default config is undefined (just that as text)
    style: "none",

    // lunr.js-specific settings
    lunr: {
      // When indexing your documents, their content is split into "tokens".
      // Text entered into the search box is also tokenized.
      // This setting configures the separator used to determine where to split the text into tokens.
      // By default, it splits the text at whitespace and dashes.
      //
      // Note: Does not work for "ja" and "th" languages, since these use a different tokenizer.
      tokenizerSeparator: /[\s\-]+/
    }
  }]
],

I have put the custom CSS variables in my custom.css & installed as per the algolia directions you noted in the link - but this approach is not working - do I need to swizzle the search component?

Many thanks for your help πŸ˜„

Wayne.

search-index-default.json doesn't exist.

Please describe the bug you are seeing

Hello,
Untitled

When i start typing it's trying to GET https://hossein-zare.github.io/react-native-dropdown-picker-website/search-index-default.json 404 but it doesn't exist.

Untitled

How can we best reproduce the bug?

No response

Which version of Docusaurus and @cmfcmf/docusaurus-search-local are you using?

"@cmfcmf/docusaurus-search-local": "^0.9.0",
"@docusaurus/core": "2.0.0-beta.13",

Which Node.js version are you using?

v16.13.0

Which theme are you using?

Yes, I am using @docusaurus/theme-classic

How does your plugin config look like?

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

Additional context

https://hossein-zare.github.io/react-native-dropdown-picker-website

TypeError: Cannot read property 'tokenizerSeparator' of undefined

TypeError: Cannot read property 'tokenizerSeparator' of undefined
at cmfcmfDocusaurusSearchLocal (/Users/gaurish/Desktop/Coding/Report-API-Docs/node_modules/@cmfcmf/docusaurus-search-local/lib/server/index.js:42:189)
at /Users/gaurish/Desktop/Coding/Report-API-Docs/node_modules/@docusaurus/core/lib/server/plugins/init.js:34:54
at Array.map ()
at Object.initPlugins (/Users/gaurish/Desktop/Coding/Report-API-Docs/node_modules/@docusaurus/core/lib/server/plugins/init.js:15:10)
at Object.loadPlugins (/Users/gaurish/Desktop/Coding/Report-API-Docs/node_modules/@docusaurus/core/lib/server/plugins/index.js:41:28)
at Object.load (/Users/gaurish/Desktop/Coding/Report-API-Docs/node_modules/@docusaurus/core/lib/server/index.js:57:62)
at start (/Users/gaurish/Desktop/Coding/Report-API-Docs/node_modules/@docusaurus/core/lib/commands/start.js:45:34)
at /Users/gaurish/Desktop/Coding/Report-API-Docs/node_modules/@docusaurus/core/bin/docusaurus.js:29:5
at Command. (/Users/gaurish/Desktop/Coding/Report-API-Docs/node_modules/@docusaurus/core/bin/docusaurus.js:93:23)
at Command.listener (/Users/gaurish/Desktop/Coding/Report-API-Docs/node_modules/@docusaurus/core/node_modules/commander/index.js:370:29)
at Command.emit (node:events:394:28)
at Command.parseArgs (/Users/gaurish/Desktop/Coding/Report-API-Docs/node_modules/@docusaurus/core/node_modules/commander/index.js:892:12)
at Command.parse (/Users/gaurish/Desktop/Coding/Report-API-Docs/node_modules/@docusaurus/core/node_modules/commander/index.js:642:21)
at Object. (/Users/gaurish/Desktop/Coding/Report-API-Docs/node_modules/@docusaurus/core/bin/docusaurus.js:116:5)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Getting this issue while running macOs, v2 of docusaurus

Cannot read property 'type' of undefined

At npm run build / yarn build, the next error appears at the end of the process (after Client and Server have compiled successfully):

TypeError: Cannot read property 'type' of undefined
at getText (/Users/escuderx/Projects/ster-website/node_modules/@cmfcmf/docusaurus-search-local/src/parse.js:54:17)
at module.exports.html2text (/Users/escuderx/Projects/ster-website/node_modules/@cmfcmf/docusaurus-search-local/src/parse.js:123:20)
at Promise.all.data.map (/Users/escuderx/Projects/ster-website/node_modules/@cmfcmf/docusaurus-search-local/src/index.js:122:45)

Override the separator

For now, lunr consider '-' to be a separator. I can't find the string 'foo-bar' in the search.
It's possible to change the way the index is built by changing the separator:

lunr.tokenizer.separator = /\s+/;

See lunr's commit here

Could we add an option in the configuration to override this property?

Search results don't navigate to the appropriate heading.

Bug description

I search for a term. The search result shows me the appropriate page and heading containing that term.
image

However, when I click on the result, I'm taken to the top of that page. Doesn't navigate to the header.

Reproduction

Build index, serve site, follow these steps

Environment

Package Versions

Docusaurus @2.0.0-alpha.70
@cmfcmf/[email protected]

Node Version

14.8.0

Docusaurus Environment

Default theme; default plugin settings

I'm thinking this should be a straightforward problem to solve?πŸ€” Retrieve the subheading and attach it as a URL fragment when navigating. I'd send in a PR for this, but I'm still finding my way around, so if anyone can point me to the appropriate parts of the codebase, that would be cool.

Search the pages/blog in all versions

Currently it's possible to search in the pages/blog only with the latest version. It's not obvious for a user to go to the latest version to find information in the pages/blog.

One way that this could be achieved is using the lunr.Query.presence.PROHIBITED field from lunr:

                versionExcluded = (...);
                if (versionToSearch) {
                  query.term(versionExcluded, {
                    fields: ["version"],
                    boost: 0,
                    presence: lunr.Query.presence.PROHIBITED,
                  });

And not link the pages and the blog to the latest version while creating the index, keep it as undefined:

          if (useDocVersioning) {
            indexDoc.version = docVersion;  // ? docVersion : docVersions[0];
          }

Docs-only mode not working

Bug description

If you use docs-only mode the indexer doesn't index directories but only the entry page.

Reproduction

Use docs-only mode described here

Environment

Package Versions

yarn list v1.22.5
β”œβ”€ @cmfcmf/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
└─ @docusaurus/[email protected]

Node Version

v15.0.1

Docusaurus Environment

Are you using a custom theme? No

docusaurus.config.js

module.exports = {
    title: 'Title',
    tagline: '',
    url: 'example.com',
    baseUrl: '/',
    favicon: 'img/favicon.ico',
    organizationName: 'org',
    projectName: 'docs',
    themeConfig: {
        sidebarCollapsible: false,
        navbar: {
            title: 'Title',
            logo: {
                alt: 'Alt text',
                src: 'img/logo.svg',
            },
            items: [
                {
                    to: '/',
                    activeBasePath: 'docs',
                    label: 'Docs',
                    position: 'left',
                },
            ],
        },
        footer: {
            style: 'dark',
            copyright: `Built with Docusaurus.`,
        },
    },
    presets: [
        [
            '@docusaurus/preset-classic',
            {
                docs: {
                    routeBasePath: '/',
                    sidebarPath: require.resolve('./sidebars.js'),
                },
                theme: {
                    customCss: require.resolve('./src/css/custom.css'),
                },
            },
        ],
    ],
    plugins: [
        [
            require.resolve('@cmfcmf/docusaurus-search-local'),
            {
                docsRouteBasePath: '/', // must correspond to the base route path configured for the docs plugin
                indexBlog: false, // whether to index blog pages
                indexDocs: true, // whether to index docs pages
                language: ['en', 'de'], // language of your documentation, see next section
                docsOnlyMode: true,
            },
        ],
    ],
};

Additional context

I introduced a new configuration option called docsOnlyMode (see above). It basically skips the URL prefix check in the flatMap function call:

if (indexDocs && docsOnlyMode) {
    return { route, url, type: "docs" };
}

...

I don't know if thats the most elegant solution but for my case it works. I can also open a PR to further discuss this issue.

Index title Bar

πŸ¦„

hello, how are you?

Would it be possible to index in the searches the heading title of the section where the doc is located?

thx

image

Indexing contains navigation buttons

Hello,

we've discovered that search results include labels on Previous / Next buttons. For instance, in the demo example here: https://christianflach.de/OpenWeatherMap-PHP-API/docs/getting-started , if I search for API Key, it will navigate me to the very bottom where the Next button is located. Is it possible to either remove it from the indexing algorithm or make it at least configurable, so that labels on those buttons won't appear in the result?

Many thanks

Lookbehind regexp causing crash on Safari

Bug description

Safari does not support yet lookbehind regexps, current SearchBar implementation causes crash - blank screen with error in console:

Unhandled Promise Rejection: SyntaxError: Invalid regular expression: invalid group specifier name

Reproduction

Opening docusarus page with in Safari browser.

Package Versions

affected in docusaurus-search-local on version >= 0.2.0, but in my case

"@cmfcmf/docusaurus-search-local": "0.3.0",
"@docusaurus/core": "2.0.0-alpha.59",
"@docusaurus/plugin-content-docs": "2.0.0-alpha.59",
"@docusaurus/plugin-content-pages": "2.0.0-alpha.59",
"@docusaurus/theme-classic": "2.0.0-alpha.59",

Node Version

14

Build breaks with "trailingSlash: false"

Bug description

Hi! Recently the Docusaurus team introduced a new configuration option trailingSlash: boolean | undefined, see here.

When specifying trailingSlash: false and using "@cmfcmf/docusaurus-search-local": "^0.6.2" the Docusaurus build breaks.

Reproduction

Add trailingSlash: false to the Docusaurus config

Error message:

[Local Search] [INFO]: Gathering documents
[Local Search] [INFO]: Parsing documents
[Local Search] [DEBUG]: Parsing blog file /build/blog/hello-world/index.html (url: /blog/hello-world)
[Local Search] [DEBUG]: Parsing blog file /build/blog/hola/index.html (url: /blog/hola)
[Local Search] [DEBUG]: Parsing blog file /build/blog/welcome/index.html (url: /blog/welcome)
[Local Search] [DEBUG]: Parsing docs file /build/docs/intro/index.html (url: /docs/intro)
[Local Search] [DEBUG]: Parsing docs file /build/docs/tutorial-basics/congratulations/index.html (url: /docs/tutorial-basics/congratulations)
[Local Search] [DEBUG]: Parsing docs file /build/docs/tutorial-basics/create-a-blog-post/index.html (url: /docs/tutorial-basics/create-a-blog-post)
[Local Search] [DEBUG]: Parsing docs file /build/docs/tutorial-basics/create-a-document/index.html (url: /docs/tutorial-basics/create-a-document)
[Local Search] [DEBUG]: Parsing docs file /build/docs/tutorial-basics/create-a-page/index.html (url: /docs/tutorial-basics/create-a-page)
[Local Search] [DEBUG]: Parsing docs file /build/docs/tutorial-basics/deploy-your-site/index.html (url: /docs/tutorial-basics/deploy-your-site)
[Local Search] [DEBUG]: Parsing docs file /build/docs/tutorial-basics/markdown-features/index.html (url: /docs/tutorial-basics/markdown-features)
[Local Search] [DEBUG]: Parsing docs file /build/docs/tutorial-extras/manage-docs-versions/index.html (url: /docs/tutorial-extras/manage-docs-versions)
[Local Search] [DEBUG]: Parsing docs file /build/docs/tutorial-extras/translate-your-site/index.html (url: /docs/tutorial-extras/translate-your-site)
Unable to build website for locale "en".
Error: ENOENT: no such file or directory, open '/build/blog/hello-world/index.html'
error Command failed with exit code 1.

You can reproduce the issue on this branch.

Environment

Package Versions

β”œβ”€ @cmfcmf/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
└─ @docusaurus/[email protected]

Node Version

  • node -v: v12.22.1

Docusaurus Environment

  • Are you using a custom theme? No
  • Paste the plugin config of the local search plugin from your docusaurus.config.js file: Default

Additional context

Issue with yarn add

Hi, thanks for a really useful plugin, I'm trying to use it in a new Docusaurus v2 project, but I get this bug when running yarn add @cmfcmf/docusaurus-search-local

yarn add v1.19.1
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
error https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.8.3.tgz: Integrity check failed for "@babel/helper-wrap-function" (computed integrity doesn't match our records, got "sha512-LACJrbUET9cQDzb6kG7EeD7+7doC3JNvUgTEQOx2qaO1fKlzE/Bf05qs9w1oXQMmXlPO65lC3Tq9S6gZpTErEQ== sha1-nb2yu1XvFKqgH+jJm2Kb1TUthhA=")
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Also, my docusaurus.config.js file has no plugin property, so I added one, I'm hoping that won't cause an issue.

SearchBar not showing up immediately

Bug description

The search bar is loaded last on the page, basically everything loads on the page and then the search bar shows up.

Any ideas on how to show the search bar immediately when the page opens up?

Reproduction

Create a Docusaurus project using the steps outlined in their website, install this plugin and add plugins: [require.resolve("@cmfcmf/docusaurus-search-local")] to docusaurus config.

Environment

Latest docusaurus version.

Package Versions

If you use Yarn:
yarn list --pattern '@docusaurus|@cmfcmf' --depth=0
If you use npm:
npm list '@docusaurus/core' '@cmfcmf/docusaurus-search-local'

Node Version

node -v

Docusaurus Environment

  • Are you using a custom theme?
  • Paste the plugin config of the local search plugin from your docusaurus.config.js file

Additional context

Change search bar position

The default search action is essentially a button in the navbar that opens a modal containing the actual search bar component. I want to remove the button and directly place the search bar component in the navbar in the center. Is this possible?

[feature request] allow specifying docs path

At the moment, the plugin expects all docs to be inside a docs folder. It would be helpful if this folder path can be passed in as an option.

Getting an SSR error whenever trying to build, so unfortunately can't provide the PR for it at the moment, but I don't believe very many changes need to be made to make this change (add to options type / validator, replace the hardcoded 'docs' with docsPath or whatever it would be called at server.index.ts:L124).

Thank you for your work on this!

Module not found when starting local development - polyfill

Bug description

Cannot start docusaurus locally, following error message is displayed in the browser

Module not found: Error: Can't resolve 'path' in '/home/paolo/workspace/wiki/node_modules/@babel/core/lib/config'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
	- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "path": false }

Additional output is provided in the terminal, all messages are very similar, they refer to buffer, assert, etc.

Reproduction

  1. Install plugin via yarn (as per readme)
  2. configure plugin in the plugin section of docusaurus config (as per readme, changed only the language, included below)
  3. try to run locally with yarn start

Environment

Package Versions

β”œβ”€ @cmfcmf/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
β”œβ”€ @docusaurus/[email protected]
└─ @docusaurus/[email protected]

Node Version

v14.17.0

Docusaurus Environment

  • Are you using a custom theme?
    No

  • Paste the plugin config of the local search plugin from your docusaurus.config.js file

[
      require.resolve('@cmfcmf/docusaurus-search-local'),
      {
        indexDocs: true,
        docsRouteBasePath: '/docs',
        indexDocSidebarParentCategories: 0,
        indexBlog: true,
        blogRouteBasePath: '/blog',
        indexPages: false,
        language: "it",
        style: undefined,
        lunr: {
          tokenizerSeparator: /[\s\-]+/
        }
      }
    ],

Additional context

Nothing to add

Match current Docusaurus search styling

Hi, great work on the plugin! Thank you!

Are you considering refreshing the styling of the autocomplete to match the current Docusaurus styling or at least display the text around the matching term. Similar to what is done here, but the indexing of yours plugin is better when it comes to matching whole phrases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.