Introduced Server Side Rendering for Cloud Pages based on React

This commit is contained in:
tmshv committed 2017-05-20 23:24:18 +03:00
1 parent 569b849457
commit 1d6772eef3
17 files changed
+456 -61

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
const {readFile} = require('async-file')
const handlebars = require('handlebars')
function notFound(templateFile) {
return async (ctx, next) => {
await next()
if (ctx.status === 404) {
const source = await readFile(templateFile, 'utf-8')
const template = handlebars.compile(source)
ctx.type = 'text/html'
ctx.body = template()
}
}
}
exports.notFound = notFound