fix(search): incorrect anchor link, fixed #90
This commit is contained in:
parent
855c450a97
commit
b8a3d8f380
5 changed files with 9 additions and 7 deletions
|
|
@ -107,7 +107,7 @@ function bindEvents () {
|
|||
e => e.target.tagName !== 'A' && e.stopPropagation())
|
||||
dom.on($input, 'input', e => {
|
||||
clearTimeout(timeId)
|
||||
timeId = setTimeout(_ => doSearch(e.target.value.trim()), 200)
|
||||
timeId = setTimeout(_ => doSearch(e.target.value.trim()), 100)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,13 +40,14 @@ function saveData (maxAge) {
|
|||
|
||||
export function genIndex (path, content = '') {
|
||||
const tokens = window.marked.lexer(content)
|
||||
const slugify = window.Docsify.slugify
|
||||
const toURL = Docsify.route.toURL
|
||||
const index = {}
|
||||
let slug
|
||||
|
||||
tokens.forEach(token => {
|
||||
if (token.type === 'heading' && token.depth <= 2) {
|
||||
slug = toURL(path, { id: token.text })
|
||||
slug = toURL(path, { id: slugify(token.text) })
|
||||
index[slug] = { slug, title: token.text, body: '' }
|
||||
} else {
|
||||
if (!slug) return
|
||||
|
|
@ -61,7 +62,7 @@ export function genIndex (path, content = '') {
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
slugify.clear()
|
||||
return index
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue