Custom Search Bar in Docusaurus 2

痞子三分冷 提交于 2020-01-25 03:56:05

问题


I'm just experimenting with Docusaurus V2, i want o enable offline search witth LUNR(https://lunrjs.com/) Search, like described, in this blog.

https://v2.docusaurus.io/feedback/p/offline-search

i also searched the docs for that.

https://v2.docusaurus.io/docs/search/#__docusaurus

I installed the with the "yarn swizzle @docusaurus/theme-classic SearchBar" command, but no search bar appeared, when running with "npm start".

Besides, a document was created with this content in src/theme/SearchBar.js:

/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

export {default} from '@docusaurus/Noop';

The documentation is really thin, what could be wrong. Is there a working example?

As described in the Blog by this video, there is a possibility. https://canny.io/images/873b18eabf90e91512ac4d0ceb48973b.gif


回答1:


You need to edit that file and implement your own searchbar component. You can do yarn swizzle @docusaurus/theme-search-algolia SearchBar instead if you want to modify it from the algolia searchbar



来源:https://stackoverflow.com/questions/58501754/custom-search-bar-in-docusaurus-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!