Fixed custom subject in email preview

This commit is contained in:
Rish 2019-11-06 18:32:11 +07:00
parent 77daa77e04
commit 6357d0c79b
2 changed files with 4 additions and 1 deletions

View File

@ -20,7 +20,7 @@ module.exports = {
], ],
permissions: true, permissions: true,
query(frame) { query(frame) {
const options = Object.assign(frame.options, {formats: 'html,plaintext', withRelated: ['authors']}); const options = Object.assign(frame.options, {formats: 'html,plaintext', withRelated: ['authors', 'posts_meta']});
const data = Object.assign(frame.data, {status: 'all'}); const data = Object.assign(frame.data, {status: 'all'});
return models.Post.findOne(data, options) return models.Post.findOne(data, options)
.then((model) => { .then((model) => {

View File

@ -13,6 +13,9 @@ const getSite = () => {
const serialize = (post) => { const serialize = (post) => {
post.published_at = post.published_at ? moment(post.published_at).format('DD MMM YYYY') : moment().format('DD MMM YYYY'); post.published_at = post.published_at ? moment(post.published_at).format('DD MMM YYYY') : moment().format('DD MMM YYYY');
post.authors = post.authors && post.authors.map(author => author.name).join(','); post.authors = post.authors && post.authors.map(author => author.name).join(',');
if (post.posts_meta) {
post.email_subject = post.posts_meta.email_subject;
}
return { return {
subject: post.email_subject || post.title, subject: post.email_subject || post.title,
html: juice(template({post, site: getSite()})), html: juice(template({post, site: getSite()})),