Skip to content

Commit

Permalink
fix: Inconsistent search and body rendering
Browse files Browse the repository at this point in the history
* fix

* Update search.js

* Update search.js

* Update search.js

* Update search.js

* Update search.js
  • Loading branch information
sy-records committed Apr 19, 2020
1 parent 39320bb commit dcb0aae
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/plugins/search/search.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit dcb0aae

Please sign in to comment.