Skip to content
This repository was archived by the owner on Oct 27, 2020. It is now read-only.

Commit fc25dc9

Browse files
committed
Use path module for link path evaluation
1 parent bc29d8e commit fc25dc9

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var path = require('path');
2+
13
module.exports = {
24
hooks: {
35
// After html generation
@@ -12,14 +14,9 @@ module.exports = {
1214
config.label = "Edit This Page";
1315
}
1416

15-
// We need to calculate the path this way because multilingual
16-
// books have wrong page.path
17-
path = "/" + page.path;
18-
if(this.options.originalInput !== undefined) {
19-
path = page.rawPath.replace(this.options.originalInput, '');
20-
}
17+
newPath = path.relative(this.options.originalInput, page.rawPath);
2118

22-
rtEditLink = '<a href="' + config.base + path + '" class="btn fa fa-edit pull-left">&nbsp;&nbsp;' + config.label + '</a>';
19+
rtEditLink = '<a href="' + config.base + '/' + newPath + '" class="btn fa fa-edit pull-left">&nbsp;&nbsp;' + config.label + '</a>';
2320

2421
page.content = page.content.replace (
2522
'<!-- Actions Right -->',

0 commit comments

Comments
 (0)