mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 18:13:29 +00:00
36 lines
962 B
JavaScript
36 lines
962 B
JavaScript
var Promise = require('../../utils/promise');
|
|
var JSONUtils = require('../../json');
|
|
var Templating = require('../../templating');
|
|
var writeFile = require('../helper/writeFile');
|
|
var createTemplateEngine = require('./createTemplateEngine');
|
|
|
|
/**
|
|
Finish the generation, write the languages index
|
|
|
|
@param {Output}
|
|
@return {Output}
|
|
*/
|
|
function onFinish(output) {
|
|
var book = output.getBook();
|
|
var options = output.getOptions();
|
|
var prefix = options.get('prefix');
|
|
|
|
if (!book.isMultilingual()) {
|
|
return Promise(output);
|
|
}
|
|
|
|
var filePath = 'index.html';
|
|
var engine = createTemplateEngine(output, filePath);
|
|
var context = JSONUtils.encodeOutput(output);
|
|
|
|
// Render the theme
|
|
return Templating.renderFile(engine, prefix + '/languages.html', context)
|
|
|
|
// Write it to the disk
|
|
.then(function(tplOut) {
|
|
return writeFile(output, filePath, tplOut.getContent());
|
|
});
|
|
}
|
|
|
|
module.exports = onFinish;
|