Skip to content

Commit

Permalink
Converted all link tags in preview to open in new tab
Browse files Browse the repository at this point in the history
no issue
  • Loading branch information
rishabhgrg committed Nov 15, 2019
1 parent 90f61d1 commit 52eb3ca
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/server/services/mega/post-email-serializer.js
Expand Up @@ -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(), {
Expand All @@ -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
};
};
Expand Down

0 comments on commit 52eb3ca

Please sign in to comment.