Skip to content

Commit 2102b69

Browse files
committed
Check if normalize is supported
1 parent d23285e commit 2102b69

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

docs/plugins.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ By default, the hyperlink on the current page is recognized and the content is s
6262
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
6363
```
6464

65+
The search ignores diacritical marks by default, but is not supported by IE. If you need support, please load this `ponyfill`
66+
67+
```html
68+
<script src="//polyfill.io/v3/polyfill.min.js?features=String.prototype.normalize"></script>
69+
```
70+
6571
## Google Analytics
6672

6773
Install the plugin and configure the track id.

src/plugins/search/search.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ export function genIndex(path, content = '', router, depth) {
132132
}
133133

134134
export function ignoreDiacriticalMarks(keyword) {
135-
return keyword.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
135+
if (keyword && keyword.normalize) {
136+
return keyword.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
137+
}
138+
return keyword;
136139
}
137140

138141
/**

0 commit comments

Comments
 (0)