feat: rendering pipeline logic

This commit is contained in:
Nicolas Giard
2018-09-09 20:33:10 -04:00
parent 0b93544677
commit 09d1f580d9
39 changed files with 210 additions and 86 deletions

View File

@@ -1,16 +1,30 @@
require('../core/worker')
const _ = require('lodash')
/* global WIKI */
WIKI.models = require('../core/db').init()
module.exports = async (job) => {
WIKI.logger.info(`Rendering page ${job.data.path}...`)
WIKI.logger.info(`Rendering page ${job.data.page.path}...`)
try {
WIKI.logger.info(`Rendering page ${job.data.path}: [ COMPLETED ]`)
let output = job.data.page.content
for (let core of job.data.pipeline) {
const renderer = require(`../modules/rendering/${_.kebabCase(core.key)}/renderer.js`)
output = await renderer.render.call({
config: core.config,
children: core.children,
page: job.data.page,
input: output
})
}
console.info(output)
WIKI.logger.info(`Rendering page ${job.data.page.path}: [ COMPLETED ]`)
} catch (err) {
WIKI.logger.error(`Rendering page ${job.data.path}: [ FAILED ]`)
WIKI.logger.error(`Rendering page ${job.data.page.path}: [ FAILED ]`)
WIKI.logger.error(err.message)
}
}