wikijs-fork/server/jobs/render-page.js

31 lines
804 B
JavaScript
Raw Normal View History

require('../core/worker')
2018-09-10 00:33:10 +00:00
const _ = require('lodash')
/* global WIKI */
2018-08-20 05:02:57 +00:00
WIKI.models = require('../core/db').init()
module.exports = async (job) => {
2018-09-10 00:33:10 +00:00
WIKI.logger.info(`Rendering page ${job.data.page.path}...`)
try {
2018-09-10 00:33:10 +00:00
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) {
2018-09-10 00:33:10 +00:00
WIKI.logger.error(`Rendering page ${job.data.page.path}: [ FAILED ]`)
WIKI.logger.error(err.message)
}
}