summaryrefslogtreecommitdiffstats
path: root/lib/output/website/onFinish.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output/website/onFinish.js')
-rw-r--r--lib/output/website/onFinish.js26
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/output/website/onFinish.js b/lib/output/website/onFinish.js
index a424250..e3560e2 100644
--- a/lib/output/website/onFinish.js
+++ b/lib/output/website/onFinish.js
@@ -1,15 +1,35 @@
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
+ Finish the generation, write the languages index
@param {Output}
@return {Output}
*/
function onFinish(output) {
- // todo: render language index
+ var book = output.getBook();
+ var options = output.getOptions();
+ var prefix = options.get('prefix');
- return Promise(output);
+ 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(html) {
+ return writeFile(output, filePath, html);
+ });
}
module.exports = onFinish;