mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
686e0143c7
no issue
24 lines
725 B
JavaScript
24 lines
725 B
JavaScript
const juice = require('juice');
|
|
const template = require('./template');
|
|
const settingsCache = require('../../services/settings/cache');
|
|
const urlUtils = require('../../lib/url-utils');
|
|
const moment = require('moment');
|
|
|
|
const getSite = () => {
|
|
return Object.assign({}, settingsCache.getPublic(), {
|
|
url: urlUtils.urlFor('home', true)
|
|
});
|
|
};
|
|
|
|
const serialize = (post) => {
|
|
post.published_at = post.published_at ? moment(post.published_at).format('DD MMM YYYY') : moment().format('DD MMM YYYY');
|
|
return {
|
|
subject: post.email_subject || post.title,
|
|
html: juice(template({post, site: getSite()})),
|
|
plaintext: post.plaintext
|
|
};
|
|
};
|
|
|
|
module.exports = {
|
|
serialize: serialize
|
|
};
|