Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b8a3d8f

Browse filesBrowse files
committed
fix(search): incorrect anchor link, fixed #90
1 parent 855c450 commit b8a3d8f
Copy full SHA for b8a3d8f

5 files changed

+9-7Lines changed: 9 additions & 7 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/core/global-api.js‎

Copy file name to clipboardExpand all lines: src/core/global-api.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import * as util from './util'
22
import * as dom from './util/dom'
33
import * as render from './render/compiler'
44
import * as route from './route/hash'
5+
import { slugify } from './render/slugify'
56
import { get } from './fetch/ajax'
67
import marked from 'marked'
78
import prism from 'prismjs'
89

910
export default function () {
10-
window.Docsify = { util, dom, render, route, get }
11+
window.Docsify = { util, dom, render, route, get, slugify }
1112
window.marked = marked
1213
window.Prism = prism
1314
}
Collapse file

‎src/core/render/compiler.js‎

Copy file name to clipboardExpand all lines: src/core/render/compiler.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import marked from 'marked'
22
import Prism from 'prismjs'
33
import { helper as helperTpl, tree as treeTpl } from './tpl'
44
import { genTree } from './gen-tree'
5-
import { slugify, clearSlugCache } from './slugify'
5+
import { slugify } from './slugify'
66
import { emojify } from './emojify'
77
import { toURL, parse } from '../route/hash'
88
import { getBasePath, isAbsolutePath, getPath } from '../route/util'
@@ -25,7 +25,7 @@ export const markdown = cached(text => {
2525

2626
html = markdownCompiler(text)
2727
html = emojify(html)
28-
clearSlugCache()
28+
slugify.clear()
2929

3030
return html
3131
})
Collapse file

‎src/core/render/slugify.js‎

Copy file name to clipboardExpand all lines: src/core/render/slugify.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ export function slugify (str) {
2222
return slug
2323
}
2424

25-
export function clearSlugCache () {
25+
slugify.clear = function () {
2626
cache = {}
2727
}
Collapse file

‎src/plugins/search/component.js‎

Copy file name to clipboardExpand all lines: src/plugins/search/component.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function bindEvents () {
107107
e => e.target.tagName !== 'A' && e.stopPropagation())
108108
dom.on($input, 'input', e => {
109109
clearTimeout(timeId)
110-
timeId = setTimeout(_ => doSearch(e.target.value.trim()), 200)
110+
timeId = setTimeout(_ => doSearch(e.target.value.trim()), 100)
111111
})
112112
}
113113

Collapse file

‎src/plugins/search/search.js‎

Copy file name to clipboardExpand all lines: src/plugins/search/search.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ function saveData (maxAge) {
4040

4141
export function genIndex (path, content = '') {
4242
const tokens = window.marked.lexer(content)
43+
const slugify = window.Docsify.slugify
4344
const toURL = Docsify.route.toURL
4445
const index = {}
4546
let slug
4647

4748
tokens.forEach(token => {
4849
if (token.type === 'heading' && token.depth <= 2) {
49-
slug = toURL(path, { id: token.text })
50+
slug = toURL(path, { id: slugify(token.text) })
5051
index[slug] = { slug, title: token.text, body: '' }
5152
} else {
5253
if (!slug) return
@@ -61,7 +62,7 @@ export function genIndex (path, content = '') {
6162
}
6263
}
6364
})
64-
65+
slugify.clear()
6566
return index
6667
}
6768

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.