Skip to content

Commit 78b3a6d

Browse files
author
cinwellli
committed
chore: fix edit docs button, fixed docsifyjs#562
1 parent 845b1f2 commit 78b3a6d

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

docs/index.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@
6262
plugins: [
6363
function (hook, vm) {
6464
hook.beforeEach(function (html) {
65-
var url = 'https://github.com/docsifyjs/docsify/blob/master/docs/' + vm.route.file
65+
if (/githubusercontent\.com/.test(vm.route.file)) {
66+
url = vm.route.file
67+
.replace('raw.githubusercontent.com', 'github.com')
68+
.replace(/\/master/, '/blob/master')
69+
} else {
70+
url = 'https://github.com/docsifyjs/docsify/blob/master/' + vm.route.file
71+
}
6672
var editHtml = '[:memo: Edit Document](' + url + ')\n'
6773

6874
return editHtml

index.html

+8-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@
4242
plugins: [
4343
function (hook, vm) {
4444
hook.beforeEach(function (html) {
45-
var url = 'https://github.com/docsifyjs/docsify/blob/master/' + vm.route.file
45+
var url
46+
if (/githubusercontent\.com/.test(vm.route.file)) {
47+
url = vm.route.file
48+
.replace('raw.githubusercontent.com', 'github.com')
49+
.replace(/\/master/, '/blob/master')
50+
} else {
51+
url = 'https://github.com/docsifyjs/docsify/blob/master/' + vm.route.file
52+
}
4653
var editHtml = '[:memo: Edit Document](' + url + ')\n'
4754

4855
return editHtml

0 commit comments

Comments
 (0)