0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Converted all link tags in preview to open in new tab

no issue
This commit is contained in:
Rish 2019-11-15 11:25:46 +05:30
parent 90f61d1f04
commit 52eb3ca9da

View file

@ -3,6 +3,7 @@ const template = require('./template');
const settingsCache = require('../../services/settings/cache');
const urlUtils = require('../../lib/url-utils');
const moment = require('moment');
const cheerio = require('cheerio');
const getSite = () => {
return Object.assign({}, settingsCache.getPublic(), {
@ -17,9 +18,14 @@ const serialize = (post) => {
if (post.posts_meta) {
post.email_subject = post.posts_meta.email_subject;
}
let juicedHtml = juice(template({post, site: getSite()}));
// Force all links to open in new tab
let _cheerio = cheerio.load(juicedHtml);
_cheerio('a').attr('target','_blank');
juicedHtml = _cheerio.html();
return {
subject: post.email_subject || post.title,
html: juice(template({post, site: getSite()})),
html: juicedHtml,
plaintext: post.plaintext
};
};