Installations
npm install @easyops-cn/docusaurus-search-local
Score
55.4
Supply Chain
45.5
Quality
90.9
Maintenance
100
Vulnerability
94.3
License
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
>=12
Typescript Support
No
Node Version
NPM Version
Statistics
717 Stars
595 Commits
93 Forks
11 Watching
7 Branches
24 Contributors
Updated on 28 Nov 2024
Languages
TypeScript (83.51%)
JavaScript (8.61%)
CSS (4.74%)
MDX (3.1%)
Shell (0.03%)
Total Downloads
Cumulative downloads
Total Downloads
4,407,749
Last day
-9%
7,330
Compared to previous day
Last week
10.2%
43,430
Compared to previous week
Last month
-1.6%
173,195
Compared to previous month
Last year
87.7%
2,366,646
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
17
Peer Dependencies
3
@easyops-cn/docusaurus-search-local
An offline/local search plugin/theme for Docusaurus v2/v3, which supports multiple languages, especially optimized for language of zh.
Originally forked from cmfcmf/docusaurus-search-local.
Then later fully rewritten with TypeScript 💪, styles polished 💅, language of Chinese supported 🇨🇳, and tests covered ✅.
- Live Demo
- Screen Shots
- Installation
- Usage
- Theme Options
- Custom Styles
- Trouble Shooting
- Further Reading
- Contributing
Live Demo
https://easyops-cn.github.io/docusaurus-search-local/
Screen Shots
Installation
1npm install --save @easyops-cn/docusaurus-search-local 2# or 3yarn add @easyops-cn/docusaurus-search-local
Usage
Add @easyops-cn/docusaurus-search-local
into your docusaurus themes.
1// In your `docusaurus.config.js`: 2module.exports = { 3 // ... Your other configurations. 4 themes: [ 5 // ... Your other themes. 6 [ 7 require.resolve("@easyops-cn/docusaurus-search-local"), 8 /** @type {import("@easyops-cn/docusaurus-search-local").PluginOptions} */ 9 ({ 10 // ... Your options. 11 // `hashed` is recommended as long-term-cache of index file is possible. 12 hashed: true, 13 // For Docs using Chinese, The `language` is recommended to set to: 14 // ``` 15 // language: ["en", "zh"], 16 // ``` 17 }), 18 ], 19 ], 20};
Notice: We present this as a theme instead of plugin now, see this comment.
Theme Options
Name | Type | Default | Description |
---|---|---|---|
indexDocs | boolean | true | Whether to index docs. |
indexBlog | boolean | true | Whether to index blog. |
indexPages | boolean | false | Whether to index pages. |
docsRouteBasePath | string | string[] | "/docs" | Base route path(s) of docs. Slash at beginning is not required. Note: for docs-only mode, this needs to be the same as routeBasePath in your @docusaurus/preset-classic config e.g., "/" . |
blogRouteBasePath | string | string[] | "/blog" | Base route path(s) of blog. Slash at beginning is not required. |
language | string | string[] | "en" | All lunr-languages supported languages, + zh 🔥. |
hashed | boolean | "filename" | "query" | false | Whether to add a hashed query when fetching index (based on the content hash of all indexed *.md in docsDir and blogDir if applicable). Setting to "filename" will save hash in filename instead of query. |
docsDir | string | string[] | "docs" | The dir(s) of docs to get the content hash, it's relative to the dir of your project. |
blogDir | string | string[] | "blog" | Just like the docsDir but applied to blog. |
removeDefaultStopWordFilter | boolean | false | Sometimes people (E.g., us) want to keep the English stop words as indexed, since they maybe are relevant in programming docs. |
removeDefaultStemmer | boolean | false | Enable this if you want to be able to search for any partial word at the cost of search performance. |
highlightSearchTermsOnTargetPage | boolean | false | Highlight search terms on target page. |
searchResultLimits | number | 8 | Limit the search results. |
searchResultContextMaxLength | number | 50 | Set the max length of characters of each search result to show. |
explicitSearchResultPath | boolean | false | Whether an explicit path to a heading should be presented on a suggestion template. |
ignoreFiles | string | RegExp | (string | RegExp)[] | [] | Set the match rules to ignore some routes. Put a string if you want an exact match, or put a regex if you want a partial match. Note: without the website base url. |
ignoreCssSelectors | string | string[] | [] | A list of css selectors to ignore when indexing each page. |
searchBarShortcut | boolean | true | Whether to enable keyboard shortcut to focus in search bar. |
searchBarShortcutHint | boolean | true | Whether to show keyboard shortcut hint in search bar. Disable it if you need to hide the hint while shortcut is still enabled. |
searchBarPosition | "auto" | "left" | "right" | "auto" | The side of the navbar the search bar should appear on. By default, it will try to autodetect based on your docusaurus config according to the docs. |
docsPluginIdForPreferredVersion | string | When you're using multi-instance of docs, set the docs plugin id which you'd like to check the preferred version with, for the search index. | |
zhUserDict | string | Provide your custom dict for language of zh, see here | |
zhUserDictPath | string | Provide the file path to your custom dict for language of zh, E.g.: path.resolve("./src/zh-dict.txt") | |
searchContextByPaths | (string | { label: string | Record<string, string>; path: string; } )[] | [] | Provide an list of sub-paths as separate search context, E.g.: ["docs", "community", "legacy/resources"] . It will create multiple search indexes by these paths. |
hideSearchBarWithNoSearchContext | boolean | false | Whether to hide the search bar when no search context was matched. By default, if searchContextByPaths is set, pages which are not matched with it will be considered as with a search context of ROOT. By setting hideSearchBarWithNoSearchContext: true , these pages will be considered as with NO search context, and the search bar will be hidden. |
useAllContextsWithNoSearchContext | boolean | false | Whether to show results from all the contexts if no context is provided. This option should not be used with hideSearchBarWithNoSearchContext: true as this would show results when there is no search context. This will duplicate indexes and might have a performance cost depending on the index sizes. |
forceIgnoreNoIndex | boolean | false | Force enable search index even if noIndex: true is set, this also affects unlisted articles. |
I18N
Since v0.25.0, we support docusaurus i18n system, and provided en
/ de
/ vi
and zh-CN
translations out of the box.
For other languages, please follow the official tutorial about how to translate plugin data. And translate theme.SearchBar.*
and theme.SearchPage.*
in i18n/*/code.json
.
Translations by options is dropped since v0.25.0.
See translation options for <0.25.0
To make this theme localized, pass a `translations` option which defaults to:1{ 2 "translations": { 3 "search_placeholder": "Search", 4 "see_all_results": "See all results", 5 "no_results": "No results.", 6 "search_results_for": "Search results for \"{{ keyword }}\"", 7 "search_the_documentation": "Search the documentation", 8 "count_documents_found": "{{ count }} document found", 9 "count_documents_found_plural": "{{ count }} documents found", 10 "no_documents_were_found": "No documents were found" 11 } 12}
Note that *_plural
can be omitted if it is the same as singular.
Custom Styles
This theme is shipped with polished styles just like the Algolia Search on the Docusaurus v2 website. Feel free to override these css custom properties (css variables) below.
Var | Default (light) | Default (dark) |
---|---|---|
--search-local-modal-background | #f5f6f7 | var(--ifm-background-color) |
--search-local-modal-shadow | inset 1px 1px 0 0 hsla(0, 0%, 100%, 0.5), 0 3px 8px 0 #555a64 | inset 1px 1px 0 0 #2c2e40, 0 3px 8px 0 #000309 |
--search-local-modal-width | 560px | - |
--search-local-modal-width-sm | 340px | - |
--search-local-spacing | 12px | - |
--search-local-hit-background | #fff | var(--ifm-color-emphasis-100) |
--search-local-hit-shadow | 0 1px 3px 0 #d4d9e1 | none |
--search-local-hit-color | #444950 | var(--ifm-font-color-base) |
--search-local-hit-height | 56px | - |
--search-local-highlight-color | var(--ifm-color-primary) | - |
--search-local-muted-color | #969faf | var(--ifm-color-secondary-darkest) |
--search-local-icon-stroke-width | 1.4 | - |
--search-local-hit-active-color | var(--ifm-color-white) | - |
E.g.:
1:root { 2 --search-local-modal-width: 480px; 3 --search-local-highlight-color: #5468ff; 4} 5 6html[data-theme="dark"] { 7 --search-local-highlight-color: #d23669; 8}
Trouble Shooting
When building your docs project, Set the env DEBUG=search-local:*
to enable debug logs.
1# In your docs project: 2DEBUG=search-local:* yarn build
In case some specific errors occurred:
-
Error: Cannot mix different versions of joi schemas
:- Try using @easyops-cn/docusaurus-search-local >= v0.16.0 with Docusaurus >= v2.0.0-alpha.73
- Try using @easyops-cn/docusaurus-search-local between v0.14.0 and v0.15.1 with Docusaurus between v2.0.0-alpha.68 and v2.0.0-alpha.72
- Or try using @easyops-cn/docusaurus-search-local <= v0.13.1 with Docusaurus <= v2.0.0-alpha.66
-
Module not found: Error: Can't resolve '@docusaurus/useRouteContext'
:- Try using @easyops-cn/docusaurus-search-local >= v0.25.0 with Docusaurus >= v2.0.0-beta.18
- Try using @easyops-cn/docusaurus-search-local < v0.25.0 with Docusaurus < v2.0.0-beta.18
Further Reading
Contributing
See contributing guide.
No vulnerabilities found.
Reason
18 commit(s) and 10 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 8/15 approved changesets -- score normalized to 5
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Warn: no topLevel permission defined: .github/workflows/gh-pages.yml:1
- Warn: no topLevel permission defined: .github/workflows/release-please.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/easyops-cn/docusaurus-search-local/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/easyops-cn/docusaurus-search-local/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/easyops-cn/docusaurus-search-local/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/easyops-cn/docusaurus-search-local/ci.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:50: update your workflow using https://app.stepsecurity.io/secureworkflow/easyops-cn/docusaurus-search-local/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/gh-pages.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/easyops-cn/docusaurus-search-local/gh-pages.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/gh-pages.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/easyops-cn/docusaurus-search-local/gh-pages.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/gh-pages.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/easyops-cn/docusaurus-search-local/gh-pages.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/gh-pages.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/easyops-cn/docusaurus-search-local/gh-pages.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release-please.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/easyops-cn/docusaurus-search-local/release-please.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-please.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/easyops-cn/docusaurus-search-local/release-please.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-please.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/easyops-cn/docusaurus-search-local/release-please.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-please.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/easyops-cn/docusaurus-search-local/release-please.yml/master?enable=pin
- Info: 0 out of 9 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 4 third-party GitHubAction dependencies pinned
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 29 are checked with a SAST tool
Reason
35 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-f9xv-q969-pqx4
Score
4.3
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to @easyops-cn/docusaurus-search-local
docusaurus-plugin-search-local
An offline/local search plugin for Docusaurus v2.
@cmfcmf/docusaurus-search-local
Local / Offline Search for Docusaurus
@docusaurus/theme-search-algolia
Algolia search component for Docusaurus.
docusaurus-lunr-search
Offline search component for Docusaurus V3