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

Add support for multilingual gitbooks #2

Merged
merged 2 commits into from
Apr 3, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use path module for link path evaluation
  • Loading branch information
aniav committed Mar 30, 2015
commit fc25dc9f3af10836df469f7ca694e71ac583954c
11 changes: 4 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var path = require('path');

module.exports = {
hooks: {
// After html generation
Expand All @@ -12,14 +14,9 @@ module.exports = {
config.label = "Edit This Page";
}

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

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

page.content = page.content.replace (
'<!-- Actions Right -->',
Expand Down