diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-08-18 21:53:07 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-08-18 21:53:07 -0700 |
commit | 6f1ef585bec7e169aacbd0c0116472334e1145c7 (patch) | |
tree | 14f19c07d58423c759659e8f23185adb27306983 /lib/generate/site/index.js | |
parent | d84acd0b82bb3cffa94d3ad591d99064efb45b7a (diff) | |
download | gitbook-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.js | 29 |
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")); |