summaryrefslogtreecommitdiffstats
path: root/lib/generate/site/index.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-08-18 21:53:07 -0700
committerSamy Pessé <samypesse@gmail.com>2014-08-18 21:53:07 -0700
commit6f1ef585bec7e169aacbd0c0116472334e1145c7 (patch)
tree14f19c07d58423c759659e8f23185adb27306983 /lib/generate/site/index.js
parentd84acd0b82bb3cffa94d3ad591d99064efb45b7a (diff)
downloadgitbook-6f1ef585bec7e169aacbd0c0116472334e1145c7.zip
gitbook-6f1ef585bec7e169aacbd0c0116472334e1145c7.tar.gz
gitbook-6f1ef585bec7e169aacbd0c0116472334e1145c7.tar.bz2
Show index on glossary page
Diffstat (limited to 'lib/generate/site/index.js')
-rw-r--r--lib/generate/site/index.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index af8711b..953522c 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -188,7 +188,36 @@ Generator.prototype.writeGlossary = function() {
var that = this;
var basePath = ".";
+ // No glossary
+ if (!this.glossaryIndexer) return Q();
+
+ // Transform the glossary to get term, description, files
+ var glossary = _.chain(this.glossaryIndexer.invertedIdx)
+ .map(function(links, id) {
+ var term = _.find(that.options.glossary, { 'id': id });
+
+ return {
+ id: id,
+ name: term.name,
+ description: term.description,
+ files: _.chain(links)
+ .map(function(link) {
+ var name = link.slice(0, -5);
+
+ if (name == "index") {
+ name = "README";
+ }
+ return that.options.navigation[name+".md"];
+ })
+ .sortBy("percent")
+ .value()
+ }
+ })
+ .sortBy("name")
+ .value();
+
return this._writeTemplate(this.glossaryTemplate, {
+ glossaryIndex: glossary,
basePath: basePath,
staticBase: path.join(basePath, "gitbook"),
}, path.join(this.options.output, "GLOSSARY.html"));