From bc29d8e7789cfead593795e78536c150455a7db5 Mon Sep 17 00:00:00 2001 From: Anna Warzecha Date: Sat, 28 Mar 2015 23:58:50 +0100 Subject: [PATCH 1/2] Add support for multilingual gitbooks --- index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 3188345..8156326 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,14 @@ module.exports = { config.label = "Edit This Page"; } - rtEditLink = '  ' + config.label + ''; + // 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, ''); + } + + rtEditLink = '  ' + config.label + ''; page.content = page.content.replace ( '', From fc25dc9f3af10836df469f7ca694e71ac583954c Mon Sep 17 00:00:00 2001 From: Anna Warzecha Date: Mon, 30 Mar 2015 20:33:18 +0200 Subject: [PATCH 2/2] Use path module for link path evaluation --- index.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 8156326..6f9dab2 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,5 @@ +var path = require('path'); + module.exports = { hooks: { // After html generation @@ -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 = '  ' + config.label + ''; + rtEditLink = '  ' + config.label + ''; page.content = page.content.replace ( '',