jschemer
Version:
A Node.js library to generate documentation for JSON Schemas
28 lines (21 loc) • 875 B
JavaScript
const { handlebars: hbs } = require(`../helpers`);
const path = require(`path`);
const {
readFile,
writeFile,
} = require(`fs`).promises;
/**
* Creates the landing page for the generated documentation
* @param {Object} An arguments hash
* @return {Promise} Resolves when the landing page is generated
*/
async function createLandingPage({ outDir, readmePath, schemas }) {
const readme = await readFile(readmePath, `utf8`);
const templatePath = path.join(__dirname, `../../components/home/home.hbs`);
const template = await readFile(templatePath, `utf8`);
const convertTemplate = hbs.compile(template);
const html = convertTemplate({ home: true, readme, schemas });
const outPath = path.join(outDir, `index.html`);
await writeFile(outPath, html, `utf8`);
}
module.exports = createLandingPage;