Introduced Server Side Rendering for Cloud Pages based on React
This commit is contained in:
1 parent
569b849457
commit
1d6772eef3
17 files changed
+456
-61
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user