Changeset View
Changeset View
Standalone View
Standalone View
lib/render-site.js
Show All 19 Lines | |||||
async function renderSite(site_description, directory) { | async function renderSite(site_description, directory) { | ||||
await bluebird.map(Object.keys(site_description), async page_name => { | await bluebird.map(Object.keys(site_description), async page_name => { | ||||
if (!(site_description[page_name] instanceof Function)) { | if (!(site_description[page_name] instanceof Function)) { | ||||
throw new Error('expected a function'); | throw new Error('expected a function'); | ||||
} | } | ||||
const result = await site_description[page_name](); | const result = await site_description[page_name](); | ||||
/* eslint-disable indent */ | |||||
typeof result === 'string' | typeof result === 'string' | ||||
? await renderPage( | ? await renderPage( | ||||
result, | result, | ||||
path.resolve(directory, `./${page_name}.html`) | path.resolve(directory, `./${page_name}.html`) | ||||
) | ) | ||||
: await renderSite(result, path.resolve(directory, page_name)); | : await renderSite(result, path.resolve(directory, page_name)); | ||||
/* eslint-enable indent */ | |||||
}); | }); | ||||
} | } | ||||
module.exports = renderSite; | module.exports = renderSite; |