mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Use custom edit on github plugin. Fix #469
This commit is contained in:
parent
d75f02fc29
commit
2d29d9534c
@ -24,7 +24,7 @@
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<!-- edit on github plugin must appear here -->
|
||||
<script src="//unpkg.com/docsify-edit-on-github@1.0.1/index.js"></script>
|
||||
<script src="scripts/docsify-edit-on-github.js"></script>
|
||||
<script>
|
||||
window.$docsify = {
|
||||
name: "asdf-vm",
|
||||
@ -62,8 +62,12 @@
|
||||
},
|
||||
plugins: [
|
||||
EditOnGithubPlugin.create(
|
||||
"https://github.com/asdf-vm/asdf/blob/master/docs/"
|
||||
),
|
||||
"https://github.com/asdf-vm/asdf/blob/master/docs/", {
|
||||
customURLs: {
|
||||
"https://raw.githubusercontent.com/asdf-vm/asdf-plugins/master/README.md": "https://github.com/asdf-vm/asdf-plugins/edit/master/README.md",
|
||||
"https://raw.githubusercontent.com/asdf-vm/asdf/master/CHANGELOG.md": "https://github.com/asdf-vm/asdf/edit/master/CHANGELOG.md"
|
||||
}
|
||||
})
|
||||
],
|
||||
};
|
||||
</script>
|
||||
|
47
docs/scripts/docsify-edit-on-github.js
Normal file
47
docs/scripts/docsify-edit-on-github.js
Normal file
@ -0,0 +1,47 @@
|
||||
;(function(win) {
|
||||
win.EditOnGithubPlugin = {}
|
||||
|
||||
function create(docBase, options) {
|
||||
options = options || {}
|
||||
title = options.title || 'Edit on github'
|
||||
customURLs = options.customURLs || {}
|
||||
var docEditBase = docBase.replace(/\/blob\//, '/edit/')
|
||||
|
||||
function editDoc(event, vm) {
|
||||
var docName = vm.route.file
|
||||
|
||||
if (docName) {
|
||||
var editLink = customURLs[docName] || 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)
|
Loading…
Reference in New Issue
Block a user