fix: get file path, fixed jrappen/sublime-distractionless/commit/81bfadd391428823191cc03eca956a2312e04d13#commitcomment-22427070

This commit is contained in:
qingwei.li 2017-06-23 16:52:37 +08:00
commit e8117e515d
No known key found for this signature in database
GPG key ID: B6DDC2F7AE80B2F4
4 changed files with 8 additions and 5 deletions

View file

@ -33,11 +33,10 @@
subMaxLevel: 0, subMaxLevel: 0,
mergeNavbar: true, mergeNavbar: true,
formatUpdated: '{MM}/{DD} {HH}:{mm}', formatUpdated: '{MM}/{DD} {HH}:{mm}',
routerMode: 'history',
plugins: [ plugins: [
function(hook, vm) { function(hook, vm) {
hook.beforeEach(function (html) { 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' var editHtml = '[:memo: Edit Document](' + url + ')\n'
return editHtml return editHtml

View file

@ -53,7 +53,7 @@
plugins: [ plugins: [
function(hook, vm) { function(hook, vm) {
hook.beforeEach(function (html) { 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' var editHtml = '[:memo: Edit Document](' + url + ')\n'
return editHtml return editHtml

View file

@ -22,7 +22,7 @@ export class History {
return this.config.basePath return this.config.basePath
} }
getFile (path) { getFile (path, isRelative) {
path = path || this.getCurrentPath() path = path || this.getCurrentPath()
const { config } = this const { config } = this
@ -33,6 +33,10 @@ export class History {
path = path === '/README.md' ? (config.homepage || path) : path path = path === '/README.md' ? (config.homepage || path) : path
path = isAbsolutePath(path) ? path : getPath(base, path) path = isAbsolutePath(path) ? path : getPath(base, path)
if (isRelative) {
path = path.replace(new RegExp(`^${base}`), '')
}
return path return path
} }

View file

@ -71,7 +71,7 @@ export class HashHistory extends History {
return { return {
path, path,
file: this.getFile(path), file: this.getFile(path, true),
query: parseQuery(query) query: parseQuery(query)
} }
} }