mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
Grouped mentions from same source in email report (#16470)
refs https://github.com/TryGhost/Team/issues/2754 Mentions from same source are already grouped together in Admin UI, with number of links for each source shown in the grouped mention. Similarly, this change updates the grouping of mentions from same source for email reports, removing any duplicate mention source from the report.
This commit is contained in:
parent
0455672832
commit
ef353db39a
@ -63,8 +63,13 @@ module.exports = {
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async renderHTML(report, recipient) {
|
||||
// Filter out mentions with duplicate source url from the report
|
||||
const uniqueMentions = report.mentions.filter((mention, index, self) => {
|
||||
return self.findIndex(m => m.sourceUrl.href === mention.sourceUrl.href) === index;
|
||||
});
|
||||
|
||||
return staffService.api.emails.renderHTML('mention-report', {
|
||||
report: report,
|
||||
mentions: uniqueMentions,
|
||||
recipient: recipient,
|
||||
hasMoreMentions: report.mentions.length > 5
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>💌 New mention{{#eq report.mentions.length 1}}{{else}}{{report.mentions.length}}s{{/eq}}</title>
|
||||
<title>💌 New mention{{#eq mentions.length 1}}{{else}}{{mentions.length}}s{{/eq}}</title>
|
||||
{{> styles}}
|
||||
</head>
|
||||
<body style="background-color: #ffffff; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.5em; margin: 0; padding: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;">
|
||||
@ -24,9 +24,9 @@
|
||||
<tr>
|
||||
<td style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 14px; vertical-align: top;">
|
||||
<p style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 20px; color: #15212A; font-weight: bold; line-height: 25px; margin: 0; margin-bottom: 15px;">Hey there,</p>
|
||||
<p style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; color: #3A464C; font-weight: normal; margin: 0; line-height: 25px; margin-bottom: 16px;">{{siteTitle}} was mentioned{{#eq report.mentions.length 1}} in:{{else}} <strong>{{report.mentions.length}} times</strong> recently. Here's where:{{/eq}}</p>
|
||||
<p style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; color: #3A464C; font-weight: normal; margin: 0; line-height: 25px; margin-bottom: 16px;">{{siteTitle}} was mentioned{{#eq mentions.length 1}} in:{{else}} <strong>{{mentions.length}} times</strong> recently. Here's where:{{/eq}}</p>
|
||||
|
||||
{{#each (limit report.mentions 5) as |mention|}}
|
||||
{{#each (limit mentions 5) as |mention|}}
|
||||
<!--[if !mso !vml]-->
|
||||
<figure style="margin:0 0 1.5em;padding:0;width:100%;">
|
||||
<a style="display:flex;min-height:148px;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen,Ubuntu,Cantarell,'Open Sans','Helvetica Neue',sans-serif;background:#F9F9FA;border-radius:3px;border:1px solid #F9F9FA;color:#15171a;text-decoration:none" href="{{mention.sourceUrl}}">
|
||||
@ -91,7 +91,7 @@
|
||||
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: auto;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; vertical-align: top; background-color: {{accentColor}}; border-radius: 5px; text-align: center;"> <a href="{{siteUrl}}ghost/#/mentions" target="_blank" style="display: inline-block; color: #ffffff; background-color: {{accentColor}}; border: solid 1px {{accentColor}}; border-radius: 5px; box-sizing: border-box; cursor: pointer; text-decoration: none; font-size: 16px; font-weight: normal; margin: 0; padding: 9px 22px 10px; border-color: {{accentColor}};">View all {{#if hasMoreMentions}}{{report.mentions.length}}{{/if}} mentions</a></td>
|
||||
<td style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; vertical-align: top; background-color: {{accentColor}}; border-radius: 5px; text-align: center;"> <a href="{{siteUrl}}ghost/#/mentions" target="_blank" style="display: inline-block; color: #ffffff; background-color: {{accentColor}}; border: solid 1px {{accentColor}}; border-radius: 5px; box-sizing: border-box; cursor: pointer; text-decoration: none; font-size: 16px; font-weight: normal; margin: 0; padding: 9px 22px 10px; border-color: {{accentColor}};">View all {{#if hasMoreMentions}}{{mentions.length}}{{/if}} mentions</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
Loading…
Reference in New Issue
Block a user