MCPcopy Index your code
hub / github.com/easyops-cn/docusaurus-search-local

github.com/easyops-cn/docusaurus-search-local @v0.55.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.55.2 ↗ · + Follow
129 symbols 324 edges 96 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

@easyops-cn/docusaurus-search-local

Npm Version CI Status Coverage Status

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

https://easyops-cn.github.io/docusaurus-search-local/

Screen Shots

Screen Shot EN

Screen Shot ZH

✨ Ask AI Support

This plugin now supports Ask AI integration! Enable AI-powered assistance directly in your documentation site to help users get instant, context-aware answers.

NOTE: Ask AI feature requires an external AI service. Please refer to the Open Ask AI Server, which is a serverless solution, and can be used for free using Vercel Hobby Plan!

Installing Ask AI

The Ask AI feature is opt-in. To enable it, you need to install the open-ask-ai package separately:

npm install --save open-ask-ai
# or
yarn add open-ask-ai

Ask AI Screenshot 1

Ask AI Screenshot 2

With Ask AI enabled, users can:

  • Get intelligent answers based on your documentation
  • Access AI assistance with a simple keyboard shortcut
  • Receive context-aware responses tailored to your content

See the askAi option in Theme Options below for configuration details.

Installation

npm install --save @easyops-cn/docusaurus-search-local
# or
yarn add @easyops-cn/docusaurus-search-local

Usage

Add @easyops-cn/docusaurus-search-local into your docusaurus themes.

// In your `docusaurus.config.js`:
module.exports = {
  // ... Your other configurations.
  themes: [
    // ... Your other themes.
    [
      require.resolve("@easyops-cn/docusaurus-search-local"),
      /** @type {import("@easyops-cn/docusaurus-search-local").PluginOptions} */
      ({
        // ... Your options.
        // `hashed` is recommended as long-term-cache of index file is possible.
        hashed: true,

        // For Docs using Chinese, it is recomended to set:
        // language: ["en", "zh"],

        // Customize the keyboard shortcut to focus search bar (default is "mod+k"):
        // searchBarShortcutKeymap: "s", // Use 'S' key
        // searchBarShortcutKeymap: "ctrl+shift+f", // Use Ctrl+Shift+F

        // If you're using `noIndex: true`, set `forceIgnoreNoIndex` to enable local index:
        // forceIgnoreNoIndex: true,

        // Enable Ask AI integration:
        // askAi: {
        //   project: "your-project-name",
        //   apiUrl: "https://your-api-url.com/api/stream",
        //   hotkey: "cmd+I", // Optional: keyboard shortcut to trigger Ask AI
        // },
      }),
    ],
  ],
};

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 | string[] [] Sometimes people (E.g., us) want to keep the English stop words as indexed, since they maybe are relevant in programming docs. Set a language list to remove their default stop word filter, true is equivalent to ["en"].
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

Extension points exported contracts — how you extend this code

RemoteWorker (Interface)
(no doc) [1 implementers]
docusaurus-search-local/src/client/theme/searchByWorker.ts
PluginOptions (Interface)
(no doc)
docusaurus-search-local/src/index.ts
UIMessage (Interface)
(no doc)
docusaurus-search-local/src/declarations.ts
UIMessageChunk (Interface)
(no doc)
docusaurus-search-local/src/declarations.ts
AskAIWidgetProps (Interface)
(no doc)
docusaurus-search-local/src/declarations.ts

Core symbols most depended-on inside this repo

search
called by 16
docusaurus-search-local/src/client/theme/searchByWorker.ts
parseKeymap
called by 14
docusaurus-search-local/src/client/utils/keymap.ts
isMacPlatform
called by 11
docusaurus-search-local/src/client/utils/platform.ts
generate
called by 11
docusaurus-search-local/src/server/utils/generate.ts
translate
called by 10
__mocks__/Translate.js
getKeymapHints
called by 8
docusaurus-search-local/src/client/utils/keymap.ts
ensureArray
called by 7
docusaurus-search-local/src/server/utils/processPluginOptions.ts
matchesKeymap
called by 6
docusaurus-search-local/src/client/utils/keymap.ts

Shape

Function 86
Interface 33
Method 5
Class 4
Enum 1

Languages

TypeScript100%

Modules by API surface

docusaurus-search-local/src/shared/interfaces.ts19 symbols
docusaurus-search-local/src/client/theme/worker.ts8 symbols
docusaurus-search-local/src/declarations.ts7 symbols
docusaurus-search-local/src/client/theme/SearchBar/SearchBar.tsx7 symbols
docusaurus-search-local/src/server/index.ts6 symbols
docusaurus-search-local/src/client/theme/searchByWorker.ts6 symbols
docusaurus-search-local/src/server/utils/processDocInfos.ts5 symbols
docusaurus-search-local/src/client/utils/smartQueries.ts5 symbols
docusaurus-search-local/src/client/utils/keymap.ts4 symbols
docusaurus-search-local/src/client/theme/SearchPage/SearchPage.tsx4 symbols
docusaurus-search-local/src/server/utils/scanDocuments.ts3 symbols
docusaurus-search-local/src/server/utils/getIndexHash.ts3 symbols

For agents

$ claude mcp add docusaurus-search-local \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact