Git Product home page Git Product logo

docusaurus-lunr-search's Introduction

Hi there 👋

image

docusaurus-lunr-search's People

Contributors

1natsu172 avatar alanwguo avatar anru avatar daddykotex avatar danielku15 avatar davidiam avatar davidmarquis avatar dependabot[bot] avatar divyabhushan avatar hinton avatar ipavlic avatar jeandcc avatar jknoxville avatar johannesdienst-askui avatar lelouch77 avatar lxix avatar mateuszsikora avatar michelhmachado avatar praveenn77 avatar rileyabr avatar shaneog avatar soysource avatar tayles avatar vitonsky avatar wrgoldstein avatar xf- avatar zachjw34 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

docusaurus-lunr-search's Issues

Support for versioning

Hi,
I am using versioning in my docs. When I search some string f.ex. firewall, it displays results for all versions.

image

I have tried to exclude router for versions other then the newest with:

[
      require.resolve('docusaurus-lunr-search'),
      {
        excludeRoutes: [
          'docs/2.4.2/**/*',
          'docs/2.4.1/**/*',
        ]
      }
],

It would be nice to point only to the newest existing document. (It can happen that in new version, some documents are removed), or display version in search results.

Hotkey for opening the search

With Algolia, you can press Ctrl+K to handily open the search bar.
With docusaurus-lunr-search, there is no such hotkey available, to my knowledge.

Is this something that can be added? I guess it would just a bit of passive JavaScript that listens for this particular keystroke, and then puts the focus in the search bar.

wrong search result for some Czech characters

Hi lelouch,
trying to use the lunr-search plugin on Docusaurus 2.0.0-beta.4 having docs in Czech language. The search engine ignores some Czech characters, e.g. the word "čas" (time) in our web pages https://help.4fastdevelopment.cz/docs/DXCAP/Lifecycle.

example

The same issue can be found in your demo web pages https://lelouch77.github.io/docusaurus-lunr-search-multilang/docs/doc3, the German word "können". You can copy it to search bar and you will see. But the another word with German characters "müssen" on the same page works fine.

Please could you check the search engine or just advise me what to set or change in docusaurus/plugin settings?
Thanks.

A little forgetfulness in the code tutorial:

a little forgetfulness in the code:

module.exports = {
  // ...
    plugins: [[ require.resolve('docusaurus-lunr-search'), {
      languages: ['en', 'de'] // language codes
    }],
}

it should be:

module.exports = {
  // ...
    plugins: [[ require.resolve('docusaurus-lunr-search'), {
      languages: ['en', 'de'] // language codes
    }] ],
}

Please stop copying my code

Hi @lelouch77,

I noticed that you copied (commit 9f7a0c9) almost the entire multi language search implementation from my library without any attribution or compliance with the license of my code. Please remove the offending code from your library or comply with the license.

Here's a list of code you copied from me:

My original code Copied code in your repo
https://github.com/cmfcmf/docusaurus-search-local/blob/41d577cb736344faea94347b364f74c4398ea8ec/src/index.js#L46-L71 https://github.com/lelouch77/docusaurus-lunr-search/blob/7baaafc12573eb39c6daa6b99b64f30ecc8f195c/src/utils.js#L5-L33
https://github.com/cmfcmf/docusaurus-search-local/blob/41d577cb736344faea94347b364f74c4398ea8ec/src/index.js#L145-L150 https://github.com/lelouch77/docusaurus-lunr-search/blob/7baaafc12573eb39c6daa6b99b64f30ecc8f195c/src/utils.js#L35-L42
Looks like you forgot to add the generated file to the .gitignore file: https://github.com/cmfcmf/docusaurus-search-local/blob/41d577cb736344faea94347b364f74c4398ea8ec/.gitignore#L1 https://github.com/lelouch77/docusaurus-lunr-search/blob/7baaafc12573eb39c6daa6b99b64f30ecc8f195c/src/lunr.client.js#L1-L5

It was a lot of work to understand and get multilingual search working.
Seeing you just copying all of that makes me sad and wonder what you'll copy next. 😕

Console error each time I click the searchbar

Expected behavior

There shouldn't have any console error when clicking the searchbar.

Actuel behavior

When hovering the searchbar, I get the following console error:

main.5fef3583.js:2 Uncaught TypeError: e.handleSearchBarToggle is not a function
    at VM893 c4f5d8e4.e9d8ad2d.js:1
    at Object.l (main.5fef3583.js:2)
    at p (main.5fef3583.js:2)
    at main.5fef3583.js:2
    at b (main.5fef3583.js:2)
    at lt (main.5fef3583.js:2)
    at at (main.5fef3583.js:2)
    at ut (main.5fef3583.js:2)
    at mt (main.5fef3583.js:2)
    at F (main.5fef3583.js:2)

However, it doesn't affect the searchbar behavior, everything works perfectly.

How to fix it

I simply modified src/theme/SearchBar/index.js at line 69 with the following:

      props.handleSearchBarToggle && props.handleSearchBarToggle(!props.isSearchBarExpanded);

I didn't go too deep to find the reason why handleSearchBarToggle wasn't defined at some point but my solution seems to fix the issue.

Maybe I should add a pull request for this ? Or maybe there is a better fix ?

Typerror in development

This happens only in the development context in current alpha of docusaurus. I don't try to search, i only moving or hovering with the mouse over the field throws the error.

Version of docusaurus

2.0.0-alpha.69

Version of docusaurus-lunr-search

2.1.9

Error

Unhandled Rejection (TypeError): can't access property "forEach", serialised is undefined

Full Exception
image

Compiled version
image

Workaround

before initAlgolia(searchDocs, searchIndex, DocSearch); because empty array & object is causing the issues.

          if(searchDocs.length === 0) {
              return;
          }

(I know an issue exists, but it has no context or information or response)

Can't resolve 'lunr'

I followed the instructions in the readme file and I get

./src/theme/SearchBar/lib/lunar-search.js
Module not found: Can't resolve 'lunr' in '...\_work\docusaurus\my-website\src\theme\SearchBar\lib'chunk 32
32.bafed9d0.js

I used docusaurus init and created the sample project. FYI, I am on Windows.

Search field never initializes

Even when running in production mode, the search field never gets enabled and removes "Loading...". I see in SearchBar/index.js that it depends on indexReady getting toggled. What mechanism affects that? My docusaurus instance is behind a login, so Algolia won't be able to crawl it. I've been under the impression that this component doesn't depend on Algolia and will simply index it locally via lunr.js. Is this correct?

Multiple chunks emit assets to the same filename server.bundle.js

Shows with the following error messages after: npm run build

node_modules/webpack/lib/Compilation.js:3864:12
node_modules/webpack/lib/Cache.js:85:6
node_modules/webpack/lib/Cache.js:39:11
node_modules/webpack/lib/cache/IdleFileCachePlugin.js:66:9
node_modules/webpack/lib/Cache.js:88:6
node_modules/tapable/lib/HookCodeFactory.js:33:10), :30:1)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
error building locale=en

Request for help, Please

Local development support

From the README.md

Note: Docusaurus search information can only be generated from a production build. Local development is currently not supported.

It would be nice to have this working in the dev server, Maybe a niche use case but I use Docusaurus as a way to render local notes, and I only ever use the development server (live reloading etc) and never generate production builds.

I know I'm likely missing something as to why this isn't possible. In the meantime if this isn't a planned feature it might be nice to hide or visually disable the search box while in dev mode.

Improve build process

I am integrating local search into my companies DocusaurusV2 website and it seems that the more popular plugins for local search are yours and cmfcmf's. I love the default styling that Aglolia and your package provides, but the build process that cmfcmf implements is cleaner (using the docusaurus postBuild lifecycle to generate the search metadata). Have you considered implementing a similar build process vs the build-search-data.js node script?
I'd be willing to contribute if you're interested!

Text in Tabs is not searchable

Some pages are using tabs to organize information. When we try searching for information that is in the tabs it does not always show in the search results, it might be that search results do come up for active tabs but not inactive ones.

Here is a CodeSandbox to reproduce the problem. Try to search for anything that is underneath a tab section and see that it does not show in the results (there are tabs in the Tab Bug section under tutorial)

I had first reported the issue to docusaurus here

Titles are truncated

I have a strange issue, I just installed this plugin but the search box shows truncated titles:

Screenshot 2020-04-23 at 16 39 35

Properties and Usage become roperties# and sage#

Lunr indexing 0 files out of 100

Lunr doesn't index any files out of my docs folder .md files

I have about 98 .md files in my docusaurus site:

> find docs/ -name '*.md' | wc -l
98

When I docusaurus build the site. it shows:

[INFO] [en] Creating an optimized production build...
[...]
docusaurus-lunr-search:: Building search docs and lunr index file
docusaurus-lunr-search:: Start scanning documents in 16 threads
docusaurus-lunr-search:: Indexing time: 454.61ms
docusaurus-lunr-search:: indexed 0 documents out of 100
docusaurus-lunr-search:: writing search-doc.json
docusaurus-lunr-search:: writing search-doc-1644309064310.json
docusaurus-lunr-search:: writing lunr-index.json
docusaurus-lunr-search:: writing lunr-index-1644309064310.json
docusaurus-lunr-search:: End of process

I do have broken links in my Markdown files, could this affect lunr indexing?

[WARNING] Docusaurus found broken links!

I'm using the following versions

My configuration in docusaurus.config.js is simply:

// ...
  plugins: [
    [
      'docusaurus-lunr-search', {
      }
    ]
  ],

Any idea what could cause this? Let me know if you need more info to reproduce it.

docusaurus-lunr-search Swizzle command fails

🐛 Bug Report

Docusaurus swizzle command fails to copy the SearchBar to src/theme/SearchBar.

Fix

  1. Install this package
npm i docusaurus-lunr-search  --save
  1. Then run
npm install

before the swizzle command to update, build, and link the packages.
2. Then run docusaurus swizzle

npm run swizzle docusaurus-lunr-search SearchBar -- --danger

The swizzle command works fine now.

fix-docusaurus-swizzle

To Reproduce

  1. Create a new Docusaurus Project (or migrate from an older one): npx @docusaurus/init@latest initi my-website classic
  2. Install the latest Docusaurus Lunr search package: npm i docusaurus-lunr-search --save
  3. Run the swizzle command: npm run swizzle docusaurus-lunr-search SearchBar -- --danger
    Runs into error.

Expected behavior

  1. swizzle success message:

Screenshot 2020-12-02 at 12 01 32

  1. SearchBar copied in the right location:

Screenshot 2020-12-02 at 11 55 26

Actual Behavior

Screenshot 2020-12-02 at 11 56 04

Your Environment

  • Docusaurus version used: 2.0.0-alpha.69
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): v12.19.0
  • Operating system and version (desktop or mobile): macOS Big Sur

Reproducible Demo

https://github.com/lelouch77/docusaurus-lunr-search.

If you skip this step, your site will not be enabled with the Lunr search box feature.

[ja] TypeError: lunr.TinySegmenter is not a constructor

i have a same problem with cmfcmf/docusaurus-search-local#12 for lang "ja"

TypeError: lunr.TinySegmenter is not a constructor
    at ${dir}/node_modules/lunr-languages/lunr.ja.js:86:21

when i put the code below to node_modules/lunr-languages/lunr.ja.js, build was successful.

require('./tinyseg.js')(lunr) // + add
var segmenter = new lunr.TinySegmenter() // インスタンス生成

thanks

Build fails with "can't resolve '@generated/lunr.client'"

Hello I added the plugin and did all the steps mentioned in the docs. However, the build fails with this error below. I'm using the latest version of docusaurus. Is there anything that I'm missing?

"@docusaurus/core": "^2.0.0-alpha.70",
"@docusaurus/preset-classic": "^2.0.0-alpha.70",

Client bundle compiled with errors therefore further build is impossible.

./src/theme/SearchBar/lib/lunar-search.js
Module not found: Error: Can't resolve '@generated/lunr.client' in '/Users/saugat/Code/docs/src/theme/SearchBar/lib'
@ ./src/theme/SearchBar/lib/lunar-search.js 1:0-41 1:41-45 1:216-220 1:391-395 1:471-475
@ ./src/theme/SearchBar/lib/DocSearch.js
@ ./src/theme/SearchBar/index.js
@ ./node_modules/@docusaurus/theme-classic/lib-next/theme/Navbar/index.js
@ ./node_modules/@docusaurus/theme-classic/lib-next/theme/Layout/index.js
@ ./node_modules/@docusaurus/theme-classic/lib-next/theme/NotFound.js
@ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
@ ./.docusaurus/routes.js
@ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
@ multi ./node_modules/@docusaurus/core/lib/client/clientEntry.js

Index sidebar left title

Hi lelouch, How would it be possible for the search engine to also index the titles of the menus in the left bar?

I have tried with indexBaseUrl: true but they don't appear.

thx

Not compatible with alpha 75 / Webpack 5

Hi, Docusaurus maintainer here

I'm testing the latest alpha 75 release (Webpack 5) on a few sites, and this one is failing to upgrade due to this plugin: nextauthjs/next-auth#1826

Error: Conflict: Multiple chunks emit assets to the same filename server.bundle.js (chunks 179 and 462)
    at /Users/sebastienlorber/Desktop/projects/next-auth/www/node_modules/webpack/lib/Compilation.js:3864:12
    at /Users/sebastienlorber/Desktop/projects/next-auth/www/node_modules/webpack/lib/Cache.js:85:6
    at /Users/sebastienlorber/Desktop/projects/next-auth/www/node_modules/webpack/lib/Cache.js:39:11
    at /Users/sebastienlorber/Desktop/projects/next-auth/www/node_modules/webpack/lib/cache/IdleFileCachePlugin.js:66:9
    at /Users/sebastienlorber/Desktop/projects/next-auth/www/node_modules/webpack/lib/Cache.js:88:6
    at eval (eval at create (/Users/sebastienlorber/Desktop/projects/next-auth/www/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:30:1)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

You have webpack optimizations here:

    configureWebpack(config) {
      const generatedFilesDir = config.resolve.alias['@generated']
      languages = utils.generateLunrClientJS(generatedFilesDir, options.languages);
      // Ensure that algolia docsearch css is its own chunk
      return {
        optimization: {
          splitChunks: {
            cacheGroups: {
              algolia: {
                name: 'algolia',
                test: /algolia\.css$/,
                chunks: `all`,
                enforce: true,
                // Set priority higher than docusaurus single-css extraction
                priority: 60,
              },
            },
          },
        },
      };
    },

Removing these optimizations makes the plugin work again on alpha 75, so I suggest to remove those for now to ensure everybody can upgrade.

Not sure why this does not work anymore though, nor why we have this error message.

Was also wondering why you need this optimization, as the algolia code/plugin is already in a distinct package. Maybe it's a legacy optim?

Unrelated: the call to generateLunrClientJS would probably be better in another lifecycle like contentLoaded() (but in practice it is probably not very important).

Feature request: Docusaurus /search page, like the equivalent algolia plugin

The Algolia plugin also has, at the bottom of the search ('Click here to see the rest of the results (n....results)')

Clicking this takes you to
yoursite.com/search which is a more standard search page. Would it be possible to create a version of this that works with Lunr, because currently your search only shows 5 results and sometimes that's not enough.

Rename package

Can this package be renamed from docusurus-lunr-search to docusaurus-lunr-search?

Error in get started installation

I follow the steps as they are in this repo, but I have the following errors:

  1. This is with yarn start or npm run start
./src/theme/SearchBar/lib/lunar-search.js
Module not found: Can't resolve '@generated/lunr.client' in 'E:\AAAPLICACIONES\DOCUSAURUS\my-website\src\theme\SearchBar\lib'
  1. This is with yarn run build or npm run build:
Client bundle compiled with errors therefore further build is impossible.
./src/theme/SearchBar/lib/lunar-search.js
Module not found: Error: Can't resolve '@generated/lunr.client' in 'E:\AAAPLICACIONES\DOCUSAURUS\my-website\src\theme\SearchBar\lib'
 @ ./src/theme/SearchBar/lib/lunar-search.js 1:0-41 1:41-45 1:216-220 1:391-395 1:471-475
 @ ./src/theme/SearchBar/lib/DocSearch.js
 @ ./src/theme/SearchBar/index.js
 @ ./src/theme/Navbar/index.js
 @ ./src/theme/Layout/index.js
 @ ./src/theme/NotFound.js
 @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
 @ ./.docusaurus/routes.js
 @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
 @ multi ./node_modules/@docusaurus/core/lib/client/clientEntry.js
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\eloyf\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 info lifecycle [email protected]~build: [email protected]
7 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build: PATH: C:\Users\eloyf\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;E:\AAAPLICACIONES\DOCUSAURUS\my-website\node_modules\.bin;C:\Python27\;C:\Python27\Scripts;C:\Python38\Scripts\;C:\Python38\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\Program Files\Java\jdk1.8.0_211\bin;C:\Program Files (x86)\Yarn\bin\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Hugo\bin;C:\xampp\php;C:\composer;C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin;C:\Users\eloyf\AppData\Local\Microsoft\WindowsApps;C:\Users\eloyf\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\eloyf\AppData\Local\Yarn\bin;C:\Users\eloyf\AppData\Local\Android\Sdk;C:\Users\eloyf\AppData\Local\Android\Sdk\platform-tools;C:\Users\eloyf\AppData\Roaming\npm;C:\Users\eloyf\AppData\Local\GitHubDesktop\bin;C:\Users\eloyf\AppData\Roaming\Composer\vendor\bin;C:\Users\eloyf\AppData\Local\Programs\Microsoft VS Code Insiders\bin
9 verbose lifecycle [email protected]~build: CWD: E:\AAAPLICACIONES\DOCUSAURUS\my-website
10 silly lifecycle [email protected]~build: Args: [ '/d /s /c', 'docusaurus build' ]
11 silly lifecycle [email protected]~build: Returned: code: 1  signal: null
12 info lifecycle [email protected]~build: Failed to exec build script
13 verbose stack Error: [email protected] build: `docusaurus build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\eloyf\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\eloyf\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1051:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid [email protected]
15 verbose cwd E:\AAAPLICACIONES\DOCUSAURUS\my-website
16 verbose Windows_NT 10.0.18363
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\eloyf\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v14.3.0
19 verbose npm  v6.14.7
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] build: `docusaurus build`
22 error Exit status 1
23 error Failed at the [email protected] build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

No Search Bar

I followed the readme file.
But after building cannot find any Search Bar.

What am I missing?

Build error in v2.1.8

The build throws an error in this line:

ref: select('.anchor', currentSection)?.properties.id,

This is Not Issue

Do you testing in netlify or build folder? i have problem when using netlify and using build folder to own server for production.

Search Not working

Hi, just want to make sure: "Note: Docusaurus search information can only be generated from a production build. Local development is currently not supported."

Build your Docusaurus project
npm run build
Serve your application
npx http-server ./build

This makes the production build. I can see SearchBox but it is not searching. I am missing something?

Thanks.

Dark Theme support

At the moment, i overwrite the style, but the variables from docusaurus should be used like i do and the support is integrated and match the colors from the project.

This id far from perfect, but no a bright overlay anymore

html[data-theme='dark'] .algolia-docsearch-suggestion--category-header,
html[data-theme='dark'] .algolia-docsearch-suggestion--wrapper,
html[data-theme='dark'] .algolia-docsearch-footer {
    background: var(--ifm-background-color);
    color: var(--ifm-font-color-base);
}

html[data-theme='dark'] .algolia-docsearch-suggestion--title {
    color: var(--ifm-font-color-base);
}

html[data-theme='dark'] .ds-cursor .algolia-docsearch-suggestion--wrapper {
    background: var(--ifm-background-surface-color);
}

Failed to install npm package on Docusaurus 2.0.0-beta.3

Get the following error when running command npm i docusaurus-lunr-search --save

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR!   peer react@"^16.8.4 || ^17.0.0" from @docusaurus/[email protected]
npm ERR!   node_modules/@docusaurus/core
npm ERR!     @docusaurus/core@"2.0.0-beta.3" from the root project
npm ERR!     peer @docusaurus/core@"^2.0.0-alpha.60 || ^2.0.0" from [email protected]
npm ERR!     node_modules/docusaurus-lunr-search
npm ERR!       docusaurus-lunr-search@"2.1.14" from the root project
npm ERR!   1 more (react-dom)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.4" from [email protected]
npm ERR! node_modules/docusaurus-lunr-search
npm ERR!   docusaurus-lunr-search@"2.1.14" 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.

Here is my package.json:

{
  "name": "developer-docs",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "docusaurus": "docusaurus",
    "start": "docusaurus start",
    "build": "docusaurus build",
    "swizzle": "docusaurus swizzle",
    "deploy": "docusaurus deploy",
    "clear": "docusaurus clear",
    "serve": "docusaurus serve",
    "write-translations": "docusaurus write-translations",
    "write-heading-ids": "docusaurus write-heading-ids"
  },
  "dependencies": {
    "@docusaurus/core": "2.0.0-beta.3",
    "@docusaurus/preset-classic": "2.0.0-beta.3",
    "@mdx-js/react": "^1.6.21",
    "@svgr/webpack": "^5.5.0",
    "clsx": "^1.1.1",
    "file-loader": "^6.2.0",
    "prism-react-renderer": "^1.2.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "url-loader": "^4.1.1"
  },
  "browserslist": {
    "production": [
      ">0.5%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@docusaurus/module-type-aliases": "^2.0.0-beta.3",
    "@tsconfig/docusaurus": "^1.0.2",
    "@types/react": "^17.0.14",
    "@types/react-helmet": "^6.1.2",
    "@types/react-router-dom": "^5.1.8",
    "typescript": "^4.3.5"
  }
}

"algolia.css URI malformed" error

When I run npm run build, I get an error like this:

algolia.css

URI malformed at decodeURI (<anonymous>)

I temporarily fixed this by replacing the background-image property in the last declaration block .algolia-autocomplete .algolia-docsearch-footer--logo in the algolia.css file with this line:

.algolia-autocomplete .algolia-docsearch-footer--logo {
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAF8AAAAGCAYAAAClzULKAAAABHNCSVQICAgIfAhkiAAAACtJREFUSEtjZBgFAxYCjANm86jFDKOBP4CJYDTwRwN/AENgAK0eTfkDGPgAKC8ABxS+xFUAAAAASUVORK5CYII=');
    ...

While it works fine, but I wonder what the cause of the problem? And how to fix this error permanently?

Unhandled Rejection (TypeError): Cannot read property 'forEach' of undefined

Function.lunr.Pipeline.load
C:\Users\Karan\Desktop\TargeV2\rust-doc\node_modules\lunr\lunr.js:575
572 | lunr.Pipeline.load = function (serialised) {
573 | var pipeline = new lunr.Pipeline
574 |

575 | serialised.forEach(function (fnName) {
576 | var fn = lunr.Pipeline.registeredFunctions[fnName]
577 |
578 | if (fn) {
View compiled
Function.lunr.Index.load
C:\Users\Karan\Desktop\TargeV2\rust-doc\node_modules\lunr\lunr.js:2286
2283 | invertedIndex = Object.create(null),
2284 | serializedInvertedIndex = serializedIndex.invertedIndex,
2285 | tokenSetBuilder = new lunr.TokenSet.Builder,
2286 | pipeline = lunr.Pipeline.load(serializedIndex.pipeline)
| ^ 2287 |
2288 | if (serializedIndex.version != lunr.version) {
2289 | lunr.utils.warn("Version mismatch when loading serialised index. Current version of lunr '" + lunr.version + "' does not match serialized index '" + serializedIndex.version + "'")
View compiled
new LunrSearchAdapter
webpack-internal:///./src/theme/SearchBar/lib/lunar-search.js:3:266
new DocSearch
C:/Users/Karan/Desktop/TargeV2/rust-doc/src/theme/SearchBar/lib/DocSearch.js:141
138 | /**
139 | * Returns the source method to be passed to autocomplete.js. It will query
140 | * the Algolia index and call the callbacks with the formatted hits.
141 | * @function getAutocompleteSource
| ^ 142 | * @param {function} transformData An optional function to transform the hits
143 | * @param {function} queryHook An optional function to transform the query
144 | * @returns {function} Method to be passed as the source option of

Getting this error when following the guide help please
!!!!!!!!

Scroll

You cannot scroll the results, in the mobile version, instead the bottom page moves.

Module not found: Error: Can't resolve '@generated/lunr.client'

  1. when i build the project, I get this feedback " Module not found: Error: Can't resolve '@generated/lunr.client' "
  2. my docusaurus.config.js like this
/** @type {import('@docusaurus/types').DocusaurusConfig} */
module.exports = {
  title: 'My Site',
  tagline: 'Dinosaurs are cool',
  url: 'https://your-docusaurus-test-site.com',
  baseUrl: '/',
  onBrokenLinks: 'throw',
  onBrokenMarkdownLinks: 'warn',
  favicon: 'img/favicon.png',
  organizationName: 'facebook', // Usually your GitHub org/user name.
  projectName: 'docusaurus', // Usually your repo name.
  themeConfig: {
    colorMode: {
      defaultMode: 'light',
      disableSwitch: true
    },
    navbar: {
      logo: {
        alt: 'My Site Logo',
        src: 'img/logo.png',
      },
      items: [
        {
          position: 'right',
          href: "https://qq.com",
          label: '联系客服',
        },
        {href: 'https://qq.com', label: '问题反馈', position: 'right'},
        {to: '/', label: '操作说明', position: 'right'},
        {to: '/', label: ' ', position: 'right', className: 'ssp_user'},
      ],
    },
  },
  presets: [
    [
      '@docusaurus/preset-classic',
      {
        docs: {
          sidebarPath: require.resolve('./sidebars.js'),
          routeBasePath: '/', 
        },
        theme: {
          customCss: require.resolve('./src/css/custom.css'),
        },
      },
    ],
    [require.resolve('docusaurus-lunr-search'), {}]
  ],
};
  1. i also found this file node_modules/docusaurus-lunr-search/src/theme/SearchBar/lib/lunar-search.js import "@generated/lunr.client", but I can't find this lib from the npm lib

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.