mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-24 03:16:40 +00:00
Dump glossary index to glossary_index.json
This commit is contained in:
@@ -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, '\\$&');
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user