summaryrefslogtreecommitdiffstats
path: root/lib/generate
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-03-31 12:31:01 -0700
committerSamy Pessé <samypesse@gmail.com>2014-03-31 12:31:01 -0700
commit4210794de64b396409af080b698a3b5894ee2c80 (patch)
tree5f7ee99c433483b837b20f9d359780008b2ea5c4 /lib/generate
parent77a4c1042c7c13327641fb057c3c203cbf868782 (diff)
downloadgitbook-4210794de64b396409af080b698a3b5894ee2c80.zip
gitbook-4210794de64b396409af080b698a3b5894ee2c80.tar.gz
gitbook-4210794de64b396409af080b698a3b5894ee2c80.tar.bz2
Fix all relative links
Diffstat (limited to 'lib/generate')
-rw-r--r--lib/generate/index.js2
-rw-r--r--lib/generate/template.js9
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js
index 56d1287..c265be3 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 8f63190..fdb3578 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")
})
);
})