fix: Inconsistent search and body rendering

* fix

* Update search.js

* Update search.js

* Update search.js

* Update search.js

* Update search.js
This commit is contained in:
Luffy 2020-04-19 22:12:55 +08:00 committed by GitHub
parent 39320bb3f4
commit dcb0aaea99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,10 +25,9 @@ function escapeHtml(string) {
'>': '>',
'"': '"',
"'": ''',
'/': '/',
};
return String(string).replace(/[&<>"'/]/g, s => entityMap[s]);
return String(string).replace(/[&<>"']/g, s => entityMap[s]);
}
function getAllPaths(router) {
@ -66,7 +65,7 @@ export function genIndex(path, content = '', router, depth) {
tokens.forEach(token => {
if (token.type === 'heading' && token.depth <= depth) {
slug = router.toURL(path, { id: slugify(token.text) });
slug = router.toURL(path, { id: slugify(escapeHtml(token.text)) });
index[slug] = { slug, title: token.text, body: '' };
} else {
if (!slug) {