diff --git a/dev.html b/dev.html index 3e290ac8f..30e88f481 100644 --- a/dev.html +++ b/dev.html @@ -33,11 +33,10 @@ subMaxLevel: 0, mergeNavbar: true, formatUpdated: '{MM}/{DD} {HH}:{mm}', - routerMode: 'history', plugins: [ function(hook, vm) { hook.beforeEach(function (html) { - var url = 'https://github.com/QingWei-Li/docsify/blob/master' + vm.router.getFile() + var url = 'https://github.com/QingWei-Li/docsify/blob/master/' + vm.route.file var editHtml = '[:memo: Edit Document](' + url + ')\n' return editHtml diff --git a/docs/index.html b/docs/index.html index 938c132d7..760317f8e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -53,7 +53,7 @@ plugins: [ function(hook, vm) { hook.beforeEach(function (html) { - var url = 'https://github.com/QingWei-Li/docsify/blob/master/docs' + vm.route.file + var url = 'https://github.com/QingWei-Li/docsify/blob/master/docs/' + vm.route.file var editHtml = '[:memo: Edit Document](' + url + ')\n' return editHtml diff --git a/src/core/router/history/base.js b/src/core/router/history/base.js index f6d8c657d..913a194da 100644 --- a/src/core/router/history/base.js +++ b/src/core/router/history/base.js @@ -22,7 +22,7 @@ export class History { return this.config.basePath } - getFile (path) { + getFile (path, isRelative) { path = path || this.getCurrentPath() const { config } = this @@ -33,6 +33,10 @@ export class History { path = path === '/README.md' ? (config.homepage || path) : path path = isAbsolutePath(path) ? path : getPath(base, path) + if (isRelative) { + path = path.replace(new RegExp(`^${base}`), '') + } + return path } diff --git a/src/core/router/history/hash.js b/src/core/router/history/hash.js index 6a2dea9eb..0130943d8 100644 --- a/src/core/router/history/hash.js +++ b/src/core/router/history/hash.js @@ -71,7 +71,7 @@ export class HashHistory extends History { return { path, - file: this.getFile(path), + file: this.getFile(path, true), query: parseQuery(query) } }