Execute script when vue exists.
This commit is contained in:
parent
d179ade7df
commit
9abae495ac
4 changed files with 22 additions and 10 deletions
|
|
@ -1,3 +1,10 @@
|
||||||
|
## 1.8.0
|
||||||
|
### Bug fixes
|
||||||
|
- Using `v-pre` skip compilation.
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- Execute script when vue exists.
|
||||||
|
|
||||||
## 1.7.4
|
## 1.7.4
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
- Fix bugs caused by the previous version
|
- Fix bugs caused by the previous version
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||

|

|
||||||
|
|
||||||
# docsify <small>1.7.4</small>
|
# docsify <small>1.7.5</small>
|
||||||
|
|
||||||
> A magical documentation site generator.
|
> A magical documentation site generator.
|
||||||
|
|
||||||
|
|
|
||||||
12
src/index.js
12
src/index.js
|
|
@ -76,11 +76,10 @@ const mainRender = function (cb) {
|
||||||
if (OPTIONS.coverpage && page !== OPTIONS.homepage) render.renderCover()
|
if (OPTIONS.coverpage && page !== OPTIONS.homepage) render.renderCover()
|
||||||
// render sidebar
|
// render sidebar
|
||||||
if (OPTIONS.loadSidebar) {
|
if (OPTIONS.loadSidebar) {
|
||||||
load(basePath + OPTIONS.loadSidebar)
|
const renderSidebar = result => { render.renderSidebar(result); cb() }
|
||||||
.then(result => {
|
|
||||||
render.renderSidebar(result)
|
load(basePath + OPTIONS.loadSidebar).then(renderSidebar,
|
||||||
cb()
|
load(OPTIONS.loadSidebar).then(renderSidebar))
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +87,8 @@ const mainRender = function (cb) {
|
||||||
|
|
||||||
// Render navbar
|
// Render navbar
|
||||||
if (OPTIONS.loadNavbar) {
|
if (OPTIONS.loadNavbar) {
|
||||||
load(basePath + OPTIONS.loadNavbar).then(render.renderNavbar)
|
load(basePath + OPTIONS.loadNavbar).then(render.renderNavbar,
|
||||||
|
() => load(OPTIONS.loadNavbar).then(render.renderNavbar))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,14 @@ export function renderArticle (content) {
|
||||||
renderTo('article', content ? markdown(content) : 'not found')
|
renderTo('article', content ? markdown(content) : 'not found')
|
||||||
if (!OPTIONS.sidebar && !OPTIONS.loadSidebar) renderSidebar()
|
if (!OPTIONS.sidebar && !OPTIONS.loadSidebar) renderSidebar()
|
||||||
|
|
||||||
if (content && typeof Vue !== 'undefined' && typeof Vuep !== 'undefined') {
|
if (content && typeof Vue !== 'undefined') {
|
||||||
const vm = new Vue({ el: 'main' }) // eslint-disable-line
|
const script = content.match('<script[^>]*?>([^<]+)</script>')
|
||||||
vm.$nextTick(_ => event.scrollActiveSidebar())
|
script && document.body.querySelector('article script').remove()
|
||||||
|
|
||||||
|
const vm = script
|
||||||
|
? new Function(`return ${script[1].trim()}`)()
|
||||||
|
: new Vue({ el: 'main' }) // eslint-disable-line
|
||||||
|
vm && vm.$nextTick(_ => event.scrollActiveSidebar())
|
||||||
}
|
}
|
||||||
if (OPTIONS.auto2top) setTimeout(() => event.scroll2Top(OPTIONS.auto2top), 0)
|
if (OPTIONS.auto2top) setTimeout(() => event.scroll2Top(OPTIONS.auto2top), 0)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue