Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[search plugin] fix fetching unnecessary links issue #653

Merged
merged 1 commit into from
Oct 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/plugins/search/search.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
let INDEXS = {}
let helper

function escapeHtml(string) {
const entityMap = {
Expand All @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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)
Expand Down