Ghost/core/server/services/mega/post-email-serializer.js
2019-11-05 12:15:50 +07:00

22 lines
530 B
JavaScript

const juice = require('juice');
const template = require('./template');
const settingsCache = require('../../services/settings/cache');
const urlUtils = require('../../lib/url-utils');
const getSite = () => {
return Object.assign({}, settingsCache.getPublic(), {
url: urlUtils.urlFor('home', true)
});
};
const serialize = (post) => {
return {
subject: post.email_subject || post.title,
html: juice(template({post, site: getSite()}))
};
};
module.exports = {
serialize: serialize
};