Add vue theme
This commit is contained in:
parent
44ac51b9c2
commit
e82b5c58bc
19 changed files with 802 additions and 104 deletions
35
src/index.js
35
src/index.js
|
|
@ -1,35 +0,0 @@
|
|||
import ajax from './ajax'
|
||||
import render from './render'
|
||||
|
||||
class Docsify {
|
||||
constructor (opts = {}) {
|
||||
Docsify.installed = true
|
||||
|
||||
this.dom = document.querySelector(opts.el || 'body')
|
||||
this.loc = document.location.pathname
|
||||
this.loc = this.loc === '/' ? 'README' : this.loc
|
||||
this.load()
|
||||
}
|
||||
|
||||
load () {
|
||||
ajax(`${this.loc}.md`).then(res => {
|
||||
const target = res.target
|
||||
if (target.status >= 400) {
|
||||
this.render('not found')
|
||||
} else {
|
||||
this.render(res.target.response)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
render (content) {
|
||||
this.dom.innerHTML = render(content)
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
if (Docsify.installed) return
|
||||
new Docsify()
|
||||
})
|
||||
|
||||
export default Docsify
|
||||
Loading…
Add table
Add a link
Reference in a new issue