fix: Update getAllPath query selector (#653)

Closes https://github.com/docsifyjs/docsify/issues/614
This commit is contained in:
程康 2018-10-23 07:59:51 +01:00 committed by cinwell.li
parent 50c2434ab5
commit f6f4e32485

View File

@ -1,5 +1,4 @@
let INDEXS = {}
let helper
function escapeHtml(string) {
const entityMap = {
@ -17,7 +16,7 @@ function escapeHtml(string) {
function getAllPaths(router) {
const paths = []
helper.dom.findAll('a:not([data-nosearch])').forEach(node => {
document.querySelectorAll('.sidebar-nav a:not(.section-link):not([data-nosearch])').forEach(node => {
const href = node.href
const originHref = node.getAttribute('href')
const path = router.parse(href).path
@ -149,8 +148,6 @@ export function search(query) {
}
export function init(config, vm) {
helper = Docsify
const isAuto = config.paths === 'auto'
const isExpired = localStorage.getItem('docsify.search.expires') < Date.now()
@ -171,7 +168,7 @@ export function init(config, vm) {
return count++
}
helper
Docsify
.get(vm.router.getFile(path), false, vm.config.requestHeaders)
.then(result => {
INDEXS[path] = genIndex(path, result, vm.router, config.depth)