UNPKG

honkit

Version:

HonKit is building beautiful books using Markdown.

35 lines (33 loc) 1.35 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.onFinish = onFinish; const promise_1 = __importDefault(require("../../utils/promise")); const json_1 = __importDefault(require("../../json")); const templating_1 = __importDefault(require("../../templating")); const writeFile_1 = __importDefault(require("../helper/writeFile")); const createTemplateEngine_1 = __importDefault(require("./createTemplateEngine")); /** Finish the generation, write the languages index @param {Output} output @return {Output} */ function onFinish(output) { const book = output.getBook(); const options = output.getOptions(); const prefix = options.get("prefix"); if (!book.isMultilingual()) { return (0, promise_1.default)(output); } const filePath = "index.html"; const engine = (0, createTemplateEngine_1.default)(output, filePath); const context = json_1.default.encodeOutput(output); // Render the theme return (templating_1.default.renderFile(engine, `${prefix}/languages.html`, context) // Write it to the disk .then((tplOut) => { return (0, writeFile_1.default)(output, filePath, tplOut.getContent()); })); }