Skip to content

Commit b4d03b5

Browse files
authored
feat: add docusaurus-search-local plugin for search (#636)
1 parent f8b8fd0 commit b4d03b5

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

website/docusaurus.config.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,25 @@ const config = {
206206
jsLoader: 'matomo.js',
207207
}
208208
}),
209-
themes: ['@docusaurus/theme-mermaid'],
209+
themes: [
210+
'@docusaurus/theme-mermaid',
211+
[
212+
require.resolve("@easyops-cn/docusaurus-search-local"),
213+
/** @type {import("@easyops-cn/docusaurus-search-local").PluginOptions} */
214+
({
215+
hashed: true,
216+
indexDocs: true,
217+
indexBlog: true,
218+
indexPages: true,
219+
highlightSearchTermsOnTargetPage: false,
220+
explicitSearchResultPath: true,
221+
searchBarPosition: "right",
222+
searchBarShortcutHint: false,
223+
language: ["zh", "en"],
224+
hideSearchBarWithNoSearchContext: true,
225+
}),
226+
],
227+
],
210228
headTags: [],
211229
markdown: {
212230
format: 'md',

website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@docusaurus/core": "^3.9.1",
2222
"@docusaurus/preset-classic": "^3.9.1",
2323
"@docusaurus/theme-mermaid": "^3.9.1",
24+
"@easyops-cn/docusaurus-search-local": "^0.52.1",
2425
"@mdx-js/react": "^3.0.0",
2526
"clsx": "^2.0.0",
2627
"docusaurus-plugin-matomo": "^0.0.8",

website/src/css/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
--ifm-code-font-size: 95%;
2929
--ifm-navbar-height: 80px;
3030
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);
31+
--search-local-modal-width: 480px;
32+
--search-local-modal-width-sm: 300px;
33+
--search-local-highlight-color: #2e8555;
3134
}
3235

3336
/* For readability concerns, you should choose a lighter palette in dark mode. */
@@ -41,6 +44,7 @@
4144
--ifm-color-primary-lightest: #4fddbf;
4245
--ifm-footer-background-color: #242526;
4346
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
47+
--search-local-highlight-color: #25c2a0;
4448
}
4549

4650
.hero {

0 commit comments

Comments
 (0)