mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Converted all link tags in preview to open in new tab
no issue
This commit is contained in:
parent
90f61d1f04
commit
52eb3ca9da
1 changed files with 7 additions and 1 deletions
|
@ -3,6 +3,7 @@ const template = require('./template');
|
||||||
const settingsCache = require('../../services/settings/cache');
|
const settingsCache = require('../../services/settings/cache');
|
||||||
const urlUtils = require('../../lib/url-utils');
|
const urlUtils = require('../../lib/url-utils');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
const getSite = () => {
|
const getSite = () => {
|
||||||
return Object.assign({}, settingsCache.getPublic(), {
|
return Object.assign({}, settingsCache.getPublic(), {
|
||||||
|
@ -17,9 +18,14 @@ const serialize = (post) => {
|
||||||
if (post.posts_meta) {
|
if (post.posts_meta) {
|
||||||
post.email_subject = post.posts_meta.email_subject;
|
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 {
|
return {
|
||||||
subject: post.email_subject || post.title,
|
subject: post.email_subject || post.title,
|
||||||
html: juice(template({post, site: getSite()})),
|
html: juicedHtml,
|
||||||
plaintext: post.plaintext
|
plaintext: post.plaintext
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue