Skip to content

Commit

Permalink
fix: get file path, fixed jrappen/sublime-distractionless/commit/81bf…
Browse files Browse the repository at this point in the history
…add391428823191cc03eca956a2312e04d13#commitcomment-22427070
  • Loading branch information
QingWei-Li committed Jun 23, 2017
1 parent 25e09df commit e8117e5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/core/router/history/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class History {
return this.config.basePath
}

getFile (path) {
getFile (path, isRelative) {
path = path || this.getCurrentPath()

const { config } = this
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/router/history/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class HashHistory extends History {

return {
path,
file: this.getFile(path),
file: this.getFile(path, true),
query: parseQuery(query)
}
}
Expand Down

0 comments on commit e8117e5

Please sign in to comment.