summaryrefslogtreecommitdiffstats
path: root/lib/generate/site/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/generate/site/index.js')
-rw-r--r--lib/generate/site/index.js51
1 files changed, 30 insertions, 21 deletions
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index 0bd2318..a694f39 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -59,10 +59,6 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate)
title: that.options.title,
description: that.options.description,
- githubAuthor: that.options.github ? that.options.github.split("/")[0] : "",
- githubId: that.options.github,
- githubHost: that.options.githubHost,
-
glossary: that.options.glossary,
summary: that.options.summary,
@@ -95,20 +91,15 @@ Generator.prototype.indexPage = function(lexed, pagePath) {
return Q();
};
-// Convert a markdown file to html
-Generator.prototype.convertFile = function(content, _input) {
+// Convert a markdown file into a normalized data set
+Generator.prototype.prepareFile = function(content, _input) {
var that = this;
- _output = _input.replace(".md", ".html");
- if (_output == "README.html") _output = "index.html";
-
var input = path.join(this.options.input, _input);
- var output = path.join(this.options.output, _output);
- var basePath = path.relative(path.dirname(output), this.options.output) || ".";
var page = {
path: _input,
- rawPath: input, // path to raw md file
+ rawPath: input,
content: content,
progress: parse.progress(this.options.navigation, _input)
};
@@ -131,14 +122,10 @@ Generator.prototype.convertFile = function(content, _input) {
return parse.lex(page.content);
})
.then(function(lexed) {
- // Index page in search
- return that.indexPage(lexed, _output)
- .then(_.constant(lexed));
- })
- .then(function(lexed) {
+ page.lexed = lexed;
+
// Get HTML generated sections
return parse.page(lexed, {
- repo: that.options.githubId,
dir: path.dirname(_input) || '/',
outdir: path.dirname(_input) || '/',
});
@@ -150,10 +137,30 @@ Generator.prototype.convertFile = function(content, _input) {
return _callHook("page");
})
.then(function() {
+ return page;
+ });
+};
+
+// Convert a markdown file to html
+Generator.prototype.convertFile = function(content, _input) {
+ var that = this;
+
+ var _output = _input.replace(".md", ".html");
+ if (_output == "README.html") _output = "index.html";
+ var output = path.join(this.options.output, _output);
+ var basePath = path.relative(path.dirname(output), this.options.output) || ".";
+
+ return this.prepareFile(content, _input)
+ .then(function(page) {
+ // Index page in search
+ return that.indexPage(page.lexed, _output).thenResolve(page);
+ })
+ .then(function(page) {
+ // Write file
return that._writeTemplate(that.template, {
progress: page.progress,
- _input: _input,
+ _input: page.path,
content: page.sections,
basePath: basePath,
@@ -161,7 +168,7 @@ Generator.prototype.convertFile = function(content, _input) {
}, output, function(html) {
page.content = html;
- return _callHook("page:after").get("content")
+ return that.callHook("page:after", page).get("content")
});
});
};
@@ -238,7 +245,9 @@ Generator.prototype.copyAssets = function() {
return Q.all(
_.map(that.plugins.list, function(plugin) {
var pluginAssets = path.join(that.options.output, "gitbook/plugins/", plugin.name);
- return plugin.copyAssets(pluginAssets);
+ return plugin.copyAssets(pluginAssets, {
+ base: that.pluginAssetsBase
+ });
})
);
});