Skip to content

Commit e1d2ddc

Browse files
committed
fix search bar
1 parent 0ee90fe commit e1d2ddc

9 files changed

Lines changed: 414 additions & 69 deletions

File tree

.idea/workspace.xml

Lines changed: 41 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

en/i18n.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
section_intro: 'Choose a document to start reading.',
3333
search_placeholder: 'Search documentation',
3434
search_no_results: 'No results',
35+
search_result_found: 'Found {count} result',
36+
search_results_found: 'Found {count} results',
37+
search_result_label: 'Search result {index}',
38+
search_clear: 'Clear search',
39+
search_shortcut_slash: 'Press / to search',
40+
search_shortcut_control_k: 'Press Control+K to search',
3541
pagination_previous: 'PREVIOUS',
3642
pagination_next: 'NEXT',
3743
last_modified: 'Last updated on {date}'

i18n.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
section_intro: '选择一个文档开始阅读。',
3333
search_placeholder: '搜索文档',
3434
search_no_results: '找不到结果',
35+
search_result_found: '找到 {count} 个结果',
36+
search_results_found: '找到 {count} 个结果',
37+
search_result_label: '搜索结果 {index}',
38+
search_clear: '清除搜索',
39+
search_shortcut_slash: '按 / 开始搜索',
40+
search_shortcut_control_k: '按 Control+K 开始搜索',
3541
pagination_previous: '上一文档',
3642
pagination_next: '下一文档',
3743
last_modified: '最后修改于 {date}'

index.html

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,38 @@
132132
<script>
133133
var zhUI = window.DLCE_I18N.zh;
134134
var enUI = window.DLCE_I18N.en;
135+
136+
function docsifyLanguageDefinitions() {
137+
return Array.prototype.map.call(
138+
document.querySelectorAll('#language-menu a[data-language-code]'),
139+
function (link) {
140+
return {
141+
code: link.dataset.languageCode,
142+
prefix: (link.dataset.languagePrefix || '').replace(/\/$/, '')
143+
};
144+
}
145+
).sort(function (left, right) {
146+
return right.prefix.length - left.prefix.length;
147+
});
148+
}
149+
150+
function docsifyLocalizedSearchText(key) {
151+
var dictionaries = window.DLCE_I18N || {};
152+
return docsifyLanguageDefinitions().reduce(function (localized, definition) {
153+
var dictionary = dictionaries[definition.code] || dictionaries.zh || {};
154+
localized[definition.prefix || '/'] = dictionary[key]
155+
|| (dictionaries.zh && dictionaries.zh[key])
156+
|| key;
157+
return localized;
158+
}, {});
159+
}
160+
161+
function docsifySearchPathNamespaces() {
162+
return docsifyLanguageDefinitions().map(function (definition) {
163+
return definition.prefix || '/';
164+
});
165+
}
166+
135167
window.$docsify = {
136168
basePath: '/Docs/',
137169
routerMode: 'hash',
@@ -219,17 +251,11 @@
219251
search: {
220252
maxAge: 86400000,
221253
paths: 'auto',
222-
placeholder: {
223-
'/en': enUI.search_placeholder,
224-
'/': zhUI.search_placeholder
225-
},
226-
noData: {
227-
'/en': enUI.search_no_results,
228-
'/': zhUI.search_no_results
229-
},
254+
placeholder: docsifyLocalizedSearchText('search_placeholder'),
255+
noData: docsifyLocalizedSearchText('search_no_results'),
230256
depth: 4,
231257
hideOtherSidebarContent: true,
232-
pathNamespaces: ['/', '/en'],
258+
pathNamespaces: docsifySearchPathNamespaces(),
233259
namespace: '/Docs'
234260
},
235261
tabs: {

lib/css/docs-app.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,11 @@ nav.app-nav {
691691
box-shadow: 0 0 0 3px color-mix(in srgb, var(--docs-accent) 22%, transparent);
692692
}
693693

694+
/* Docsify v5 renders search results without the v4-only `.show` class. */
695+
.sidebar .search .results-panel:not(:empty) {
696+
display: block;
697+
}
698+
694699
.sidebar-nav {
695700
flex: 1 1 auto;
696701
order: 1;

lib/data/last-modified.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"schemaVersion": 1,
3-
"generatedAt": "2026-08-14T08:58:28.000Z",
3+
"generatedAt": "2026-08-15T04:01:41.000Z",
44
"files": {
55
"_404.md": {
66
"updatedAt": "2024-08-11T15:00:07.000Z",
77
"commit": "b50e9fc1cb619edcc5bda37d1fe0d4cbfe308455"
88
},
99
"_navbar.md": {
10-
"updatedAt": "2026-08-14T04:49:12.000Z",
11-
"commit": "c413eb8455117492a5d11cbbd151843f4e5e6db5"
10+
"updatedAt": "2026-08-15T02:27:09.000Z",
11+
"commit": "2da5e5d306fd2de576635704e83467ea220d98bb"
1212
},
1313
"_sidebar.md": {
1414
"updatedAt": "2026-08-13T19:13:25.000Z",
@@ -79,20 +79,20 @@
7979
"commit": "886d5bf7d3bf5fa16b15a9d2da37f6698b54a8ac"
8080
},
8181
"dlce/settings/general.md": {
82-
"updatedAt": "2026-08-14T08:58:28.000Z",
83-
"commit": "886d5bf7d3bf5fa16b15a9d2da37f6698b54a8ac"
82+
"updatedAt": "2026-08-14T20:07:38.000Z",
83+
"commit": "85c38513c41b01c1f0ea65696037320af6feec79"
8484
},
8585
"dlce/versions.md": {
86-
"updatedAt": "2026-08-14T03:29:30.000Z",
87-
"commit": "dc3f8099a02cfff32e998d12bc94d02e7d9c5b04"
86+
"updatedAt": "2026-08-14T17:11:37.000Z",
87+
"commit": "dafcc5ab1b473f62369edb1c7002afea46ef7953"
8888
},
8989
"en/_404.md": {
9090
"updatedAt": "2024-08-11T15:00:07.000Z",
9191
"commit": "b50e9fc1cb619edcc5bda37d1fe0d4cbfe308455"
9292
},
9393
"en/_navbar.md": {
94-
"updatedAt": "2026-08-14T04:49:12.000Z",
95-
"commit": "c413eb8455117492a5d11cbbd151843f4e5e6db5"
94+
"updatedAt": "2026-08-15T02:27:09.000Z",
95+
"commit": "2da5e5d306fd2de576635704e83467ea220d98bb"
9696
},
9797
"en/_sidebar.md": {
9898
"updatedAt": "2026-08-13T10:07:20.000Z",
@@ -143,8 +143,8 @@
143143
"commit": "886d5bf7d3bf5fa16b15a9d2da37f6698b54a8ac"
144144
},
145145
"en/dlce/settings/general.md": {
146-
"updatedAt": "2026-08-14T08:58:28.000Z",
147-
"commit": "886d5bf7d3bf5fa16b15a9d2da37f6698b54a8ac"
146+
"updatedAt": "2026-08-14T20:08:59.000Z",
147+
"commit": "28619e1aad5f8d494dc5886d86d38800057d2c23"
148148
},
149149
"en/legal/_sidebar.md": {
150150
"updatedAt": "2026-08-13T10:07:20.000Z",
@@ -199,8 +199,8 @@
199199
"commit": "0f895ffa5b84f39a3c81dd8d7fdd6c0661bc2051"
200200
},
201201
"social/_sidebar.md": {
202-
"updatedAt": "2026-08-14T03:29:30.000Z",
203-
"commit": "dc3f8099a02cfff32e998d12bc94d02e7d9c5b04"
202+
"updatedAt": "2026-08-14T09:32:50.000Z",
203+
"commit": "3117f02250ce807127f24f3873223355cd5e1b7d"
204204
},
205205
"social/home.md": {
206206
"updatedAt": "2026-07-01T22:20:00.000Z",

0 commit comments

Comments
 (0)