🐛 Fixed page vs post preview template picking

refs 0c097f6532

- When viewed in "preview" context pages resolved to a "post" template instead. The bug was introduced with the referenced commit during post resource's `page` property migration
This commit is contained in:
Naz 2022-05-24 15:24:12 +08:00 committed by naz
parent 4fa412c880
commit 5569844019

View File

@ -190,7 +190,7 @@ module.exports.setTemplate = function setTemplate(req, res, data) {
} else if (res.routerOptions.type === 'custom') {
res._template = _private.pickTemplate(res.routerOptions.templates, res.routerOptions.defaultTemplate);
} else if (res.routerOptions.type === 'entry') {
if (res.routerOptions?.context?.includes('page')) {
if (res.routerOptions?.context?.includes('page') || (res.routerOptions?.context?.includes('preview') && data.page)) {
res._template = _private.getTemplateForEntry(data.page, 'page');
} else {
res._template = _private.getTemplateForEntry(data.post, 'post');