Skip to content

Commit e8117e5

Browse files
committed
fix: get file path, fixed jrappen/sublime-distractionless/commit/81bfadd391428823191cc03eca956a2312e04d13#commitcomment-22427070
1 parent 25e09df commit e8117e5

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

dev.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@
3333
subMaxLevel: 0,
3434
mergeNavbar: true,
3535
formatUpdated: '{MM}/{DD} {HH}:{mm}',
36-
routerMode: 'history',
3736
plugins: [
3837
function(hook, vm) {
3938
hook.beforeEach(function (html) {
40-
var url = 'https://github.com/QingWei-Li/docsify/blob/master' + vm.router.getFile()
39+
var url = 'https://github.com/QingWei-Li/docsify/blob/master/' + vm.route.file
4140
var editHtml = '[:memo: Edit Document](' + url + ')\n'
4241

4342
return editHtml

docs/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
plugins: [
5454
function(hook, vm) {
5555
hook.beforeEach(function (html) {
56-
var url = 'https://github.com/QingWei-Li/docsify/blob/master/docs' + vm.route.file
56+
var url = 'https://github.com/QingWei-Li/docsify/blob/master/docs/' + vm.route.file
5757
var editHtml = '[:memo: Edit Document](' + url + ')\n'
5858

5959
return editHtml

src/core/router/history/base.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class History {
2222
return this.config.basePath
2323
}
2424

25-
getFile (path) {
25+
getFile (path, isRelative) {
2626
path = path || this.getCurrentPath()
2727

2828
const { config } = this
@@ -33,6 +33,10 @@ export class History {
3333
path = path === '/README.md' ? (config.homepage || path) : path
3434
path = isAbsolutePath(path) ? path : getPath(base, path)
3535

36+
if (isRelative) {
37+
path = path.replace(new RegExp(`^${base}`), '')
38+
}
39+
3640
return path
3741
}
3842

src/core/router/history/hash.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class HashHistory extends History {
7171

7272
return {
7373
path,
74-
file: this.getFile(path),
74+
file: this.getFile(path, true),
7575
query: parseQuery(query)
7676
}
7777
}

0 commit comments

Comments
 (0)