Skip to content

Commit

Permalink
feat: #9533, allow redirect in build hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed May 7, 2021
1 parent d8a8864 commit f6b583b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/middleware/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ module.exports = function (middleware) {
options.bodyClass = buildBodyClass(req, res, options);

const buildResult = await plugins.hooks.fire(`filter:${template}.build`, { req: req, res: res, templateData: options });
if (res.headersSent) {
return;
}
const templateToRender = buildResult.templateData.templateToRender || template;

const renderResult = await plugins.hooks.fire('filter:middleware.render', { req: req, res: res, templateData: buildResult.templateData });
if (res.headersSent) {
return;
}
options = renderResult.templateData;
options._header = {
tags: await meta.tags.parse(req, renderResult, res.locals.metaTags, res.locals.linkTags),
Expand Down

0 comments on commit f6b583b

Please sign in to comment.