From 4210794de64b396409af080b698a3b5894ee2c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Mon, 31 Mar 2014 12:31:01 -0700 Subject: [PATCH] Fix all relative links --- lib/generate/index.js | 2 +- lib/generate/template.js | 9 +++++++-- templates/includes/book/summary.html | 8 ++++---- templates/layout.html | 6 +++--- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/generate/index.js b/lib/generate/index.js index 56d1287ca..c265be32f 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -17,7 +17,7 @@ var generate = function(root, output, options) { github: null }); - if (!options.github) return Q.reject(new Error("Need options.github for specifing the github origin")); + if (!options.github || !options.title) return Q.reject(new Error("Need options.github and optiosn.title")); // List all files in the repository return Q.nfcall(glob, "**/*", { diff --git a/lib/generate/template.js b/lib/generate/template.js index 8f631907c..fdb35780a 100644 --- a/lib/generate/template.js +++ b/lib/generate/template.js @@ -22,9 +22,12 @@ var initTemplate = function(options) { }); return function(input, output, local) { + var _input = input; input = path.join(options.root, input); output = path.join(options.output, output); + var basePath = path.relative(path.dirname(output), options.output) || "."; + // Read markdown file return fs.readFile(input, "utf-8") @@ -37,8 +40,10 @@ var initTemplate = function(options) { .then(function(sections) { return tpl( _.extend(local || {}, options.locals, { - _input: input, - content: sections + _input: _input, + content: sections, + basePath: basePath, + staticBase: path.join(basePath, "gitbook") }) ); }) diff --git a/templates/includes/book/summary.html b/templates/includes/book/summary.html index 65fd39863..99c226cc1 100644 --- a/templates/includes/book/summary.html +++ b/templates/includes/book/summary.html @@ -1,20 +1,20 @@