Skip to content

Commit 1157a51

Browse files
author
AniaMakes
committed
improved the canAllGraphicsBeSyndicated functionality
1 parent 53a2f41 commit 1157a51

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

server/lib/enrich/article.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ module.exports = exports = function article(content, format) {
3333

3434
content.hasGraphics = Boolean(content.contentStats && content.contentStats.graphics);
3535

36-
const countOfGraphics = content.contentStats && content.contentStats.graphics;
37-
const countOfSharableGraphics = content.embeds ? content.embeds.filter(embed => embed && embed.type.endsWith('Graphic') && embed.canBeSyndicated === 'yes').length : 0;
36+
// Currently embeds can have more than one item for each picture - for different screen sizes
37+
// We are assuming that canBeSyndicated is the same for all sizes of a picture
38+
// We are asking if ALL Graphics can be syndicated, which means as long as at least one item
39+
// can't be, the answer to this is 'no'
40+
const atLeastOneGraphicCantBeShared = content.embeds && content.embeds.filter(embed => embed && embed.type.endsWith('Graphic')).some(item => item.canBeSyndicated !== 'yes');
3841

39-
content.canAllGraphicsBeSyndicated = countOfGraphics > 0 ? countOfSharableGraphics < countOfGraphics : false;
42+
content.canAllGraphicsBeSyndicated = Boolean(atLeastOneGraphicCantBeShared);
4043

4144
if (content.bodyHTML) {
4245
content.document = formatArticleXML(`<body>${content.bodyHTML}</body>`);

0 commit comments

Comments
 (0)