forked from armory3d/armory_docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docsify-edit-on-github.js
45 lines (37 loc) · 1.03 KB
/
docsify-edit-on-github.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
;(function(win) {
win.EditOnGithubPlugin = {}
function create(docBase, docEditBase, title) {
title = title || 'Edit on github'
docEditBase = docBase.replace(/\/blob\//, '/edit/')
function editDoc(event, vm) {
var docName = vm.route.file
if (docName) {
var editLink = docEditBase + docName
window.open(editLink)
event.preventDefault()
return false
} else {
return true
}
}
win.EditOnGithubPlugin.editDoc = editDoc
return function(hook, vm) {
win.EditOnGithubPlugin.onClick = function(event) {
EditOnGithubPlugin.editDoc(event, vm)
}
var header = [
'<div style="overflow: auto">',
'<p style="float: right"><a href="',
docBase,
'" target="_blank" onclick="EditOnGithubPlugin.onClick(event)">',
title,
'</a></p>',
'</div>'
].join('')
hook.afterEach(function (html) {
return header + html
})
}
}
win.EditOnGithubPlugin.create = create
}) (window)