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 079bd00

Browse filesBrowse files
committed
refactor(plugins): update search plugin
1 parent 86594a3 commit 079bd00
Copy full SHA for 079bd00

22 files changed

+348-393Lines changed: 348 additions & 393 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

‎.eslintrc‎

Copy file name to clipboardExpand all lines: .eslintrc
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
"extends": ["vue"],
33
"env": {
44
"browser": true
5+
},
6+
"globals": {
7+
"Docsify": true,
8+
"$docsify": true
59
}
610
}
Collapse file

‎build/build.js‎

Copy file name to clipboardExpand all lines: build/build.js
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,26 @@ build({
3232
plugins: [commonjs(), nodeResolve()]
3333
})
3434

35-
// build({
36-
// entry: 'plugins/search.js',
37-
// output: 'plugins/search.js',
38-
// moduleName: 'D.Search'
39-
// })
35+
build({
36+
entry: 'plugins/search/index.js',
37+
output: 'plugins/search.js',
38+
moduleName: 'D.Search'
39+
})
4040

41-
// build({
42-
// entry: 'plugins/ga.js',
43-
// output: 'plugins/ga.js',
44-
// moduleName: 'D.GA'
45-
// })
41+
build({
42+
entry: 'plugins/ga.js',
43+
output: 'plugins/ga.js',
44+
moduleName: 'D.GA'
45+
})
4646

4747
if (isProd) {
4848
build({
49-
entry: 'index.js',
49+
entry: 'core/index.js',
5050
output: 'docsify.min.js',
5151
plugins: [commonjs(), nodeResolve(), uglify()]
5252
})
5353
build({
54-
entry: 'plugins/search.js',
54+
entry: 'plugins/search/index.js',
5555
output: 'plugins/search.min.js',
5656
moduleName: 'D.Search',
5757
plugins: [uglify()]
Collapse file

‎docs/index.html‎

Copy file name to clipboardExpand all lines: docs/index.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
1111
</head>
1212
<body>
13-
<nav>
13+
<nav data-cloak>
1414
<a href="#/">En</a>
1515
<a href="#/zh-cn/">中文</a>
1616
</nav>
Collapse file

‎docs/plugins.md‎

Copy file name to clipboardExpand all lines: docs/plugins.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ window.$docsify = {
9090
})
9191

9292
hook.ready(function() {
93-
// Called after initialization is complete. Only trigger once, no arguments.
93+
// Called after initial completion, no arguments.
9494
})
9595
}
9696
]
Collapse file

‎docs/zh-cn/plugins.md‎

Copy file name to clipboardExpand all lines: docs/zh-cn/plugins.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ window.$docsify = {
8585
})
8686

8787
hook.ready(function() {
88-
// 初始化完成后调用,只调用一次,没有参数。
88+
// 初始化并第一次加完成数据后调用,没有参数。
8989
})
9090
}
9191
]
Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"build": "rm -rf lib themes && node build/build.js && mkdir lib/themes && mkdir themes && node build/build-css.js",
1313
"dev:build": "rm -rf lib themes && mkdir themes && node build/build.js --dev && node build/build-css.js --dev",
1414
"dev": "node app.js & nodemon -w src -e js,css --exec 'npm run dev:build'",
15-
"test": "eslint src test"
15+
"test": "eslint src"
1616
},
1717
"repository": {
1818
"type": "git",
Collapse file

‎src/core/config.js‎

Copy file name to clipboardExpand all lines: src/core/config.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ if (script) {
3939
if (config.name === true) config.name = ''
4040
}
4141

42+
window.$docsify = config
43+
4244
export default config
Collapse file

‎src/core/event/scroll.js‎

Copy file name to clipboardExpand all lines: src/core/event/scroll.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export function scrollActiveSidebar () {
4545
const li = nav[last.getAttribute('data-id')]
4646

4747
if (!li || li === active) return
48-
if (active) active.classList.remove('active')
4948

49+
active && active.classList.remove('active')
5050
li.classList.add('active')
5151
active = li
5252

@@ -79,7 +79,7 @@ export function scrollActiveSidebar () {
7979

8080
export function scrollIntoView (id) {
8181
const section = dom.find('#' + id)
82-
section && setTimeout(() => section.scrollIntoView(), 0)
82+
section && section.scrollIntoView()
8383
}
8484

8585
const scrollEl = dom.$.scrollingElement || dom.$.documentElement
Collapse file

‎src/core/fetch/index.js‎

Copy file name to clipboardExpand all lines: src/core/fetch/index.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,16 @@ export function fetchMixin (proto) {
5757
.then(text => this._renderCover(text))
5858
}
5959

60-
proto.$fetch = function () {
60+
proto.$fetch = function (cb = noop) {
6161
this._fetchCover()
6262
this._fetch(result => {
6363
this.$resetEvents()
6464
callHook(this, 'doneEach')
65+
cb()
6566
})
6667
}
6768
}
6869

6970
export function initFetch (vm) {
70-
vm.$fetch()
71+
vm.$fetch(_ => callHook(vm, 'ready'))
7172
}
Collapse file

‎src/core/global-api.js‎

Copy file name to clipboardExpand all lines: src/core/global-api.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as util from './util'
22
import * as dom from './util/dom'
33
import * as render from './render/compiler'
4-
import * as route from './route/util'
4+
import * as route from './route/hash'
55
import { get } from './fetch/ajax'
66
import marked from 'marked'
77
import prism from 'prismjs'

0 commit comments

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