summaryrefslogtreecommitdiffstats
path: root/lib/generators/site.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-01-22 21:52:13 +0100
committerSamy Pessé <samypesse@gmail.com>2015-01-22 21:52:13 +0100
commit0c8513801c131ec6e2c7b348403a4c66a9bf2a11 (patch)
tree0d30ae9e895d930ad2d7a9bed0c6fbee3d8e59b3 /lib/generators/site.js
parent90789aa5b92a17825c6d98beced5abc3794f4d84 (diff)
downloadgitbook-0c8513801c131ec6e2c7b348403a4c66a9bf2a11.zip
gitbook-0c8513801c131ec6e2c7b348403a4c66a9bf2a11.tar.gz
gitbook-0c8513801c131ec6e2c7b348403a4c66a9bf2a11.tar.bz2
Write glossary for website
Diffstat (limited to 'lib/generators/site.js')
-rw-r--r--lib/generators/site.js22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/generators/site.js b/lib/generators/site.js
index d5a0c08..51a6cb3 100644
--- a/lib/generators/site.js
+++ b/lib/generators/site.js
@@ -89,6 +89,7 @@ Generator.prototype.prepareTemplates = function() {
Generator.prototype.finish = function() {
return this.copyAssets()
.then(this.copyCover)
+ .then(this.writeGlossary)
};
// Normalize a link to .html and convert README -> index
@@ -131,16 +132,21 @@ Generator.prototype.writeParsedFile = function(page) {
// Write the index for langs
Generator.prototype.langsIndex = function(langs) {
var that = this;
- var basePath = ".";
return this._writeTemplate(this.langsTemplate, {
- langs: langs,
-
- basePath: basePath,
- staticBase: path.join(basePath, "gitbook"),
+ langs: langs
}, path.join(this.options.output, "index.html"));
};
+// Write glossary
+Generator.prototype.writeGlossary = function() {
+ var that = this;
+
+ // No glossary
+ if (this.book.glossary.length == 0) return Q();
+
+ return this._writeTemplate(this.glossaryTemplate, {}, path.join(this.options.output, "GLOSSARY.html"));
+};
// Convert a page into a normalized data set
Generator.prototype.normalizePage = function(page) {
@@ -189,7 +195,10 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate)
pluginsConfig: JSON.stringify(that.options.pluginsConfig),
htmlSnippet: _.partialRight(that.plugins.html, that, options),
- options: that.options
+ options: that.options,
+
+ basePath: ".",
+ staticBase: path.join(".", "gitbook"),
}, options)
);
})
@@ -202,7 +211,6 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate)
});
};
-
// Copy assets
Generator.prototype.copyAssets = function() {
var that = this;