summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-08-18 21:32:10 -0700
committerSamy Pessé <samypesse@gmail.com>2014-08-18 21:32:10 -0700
commitd84acd0b82bb3cffa94d3ad591d99064efb45b7a (patch)
tree64853d734586a03620e586cca89f734d9b43c2c3
parente1723ad3d5024736e88ae1cefaa6079cb9410ac1 (diff)
downloadgitbook-d84acd0b82bb3cffa94d3ad591d99064efb45b7a.zip
gitbook-d84acd0b82bb3cffa94d3ad591d99064efb45b7a.tar.gz
gitbook-d84acd0b82bb3cffa94d3ad591d99064efb45b7a.tar.bz2
Dump glossary index to glossary_index.json
-rw-r--r--lib/generate/site/glossary_indexer.js6
-rw-r--r--lib/generate/site/index.js11
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/generate/site/glossary_indexer.js b/lib/generate/site/glossary_indexer.js
index 6360cfc..da653c8 100644
--- a/lib/generate/site/glossary_indexer.js
+++ b/lib/generate/site/glossary_indexer.js
@@ -63,8 +63,6 @@ Indexer.prototype.text = function(nodes) {
// Add page to glossary index
Indexer.prototype.add = function(sections, url) {
if(!(this.glossary && this.glossary.length > 0)) {
- console.log('Glossary =', this.glossary);
- console.log('No glossary to match');
return;
}
@@ -91,6 +89,10 @@ Indexer.prototype.add = function(sections, url) {
};
+Indexer.prototype.dump = function() {
+ return JSON.stringify(this.idx);
+};
+
function regexEscape(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index 588ffdb..af8711b 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -223,11 +223,22 @@ Generator.prototype.writeSearchIndex = function() {
);
};
+// Dump glossary index to disk
+Generator.prototype.writeGlossaryIndex = function() {
+ if (!this.glossaryIndexer) return Q();
+
+ return fs.writeFile(
+ path.join(this.options.output, 'glossary_index.json'),
+ this.glossaryIndexer.dump()
+ );
+};
+
Generator.prototype.finish = function() {
return this.copyAssets()
.then(this.copyCover)
.then(this.writeGlossary)
+ .then(this.writeGlossaryIndex)
.then(this.writeSearchIndex);
};