From 2e5fcafb040edc53198796bc444bbb2ec51156b6 Mon Sep 17 00:00:00 2001 From: Bryan Stopp Date: Tue, 16 Apr 2024 15:13:21 +0200 Subject: [PATCH] Fix Author Teaser (#307) --- .../blocks/author-teaser/author-teaser.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cigaradvisor/blocks/author-teaser/author-teaser.js b/cigaradvisor/blocks/author-teaser/author-teaser.js index e184701..9894e8d 100644 --- a/cigaradvisor/blocks/author-teaser/author-teaser.js +++ b/cigaradvisor/blocks/author-teaser/author-teaser.js @@ -1,6 +1,10 @@ import { decorateSeoPicture, fetchAuthorInfo } from '../../scripts/scripts.js'; import { decorateIcons, createOptimizedPicture } from '../../scripts/aem.js'; +function checkValue(val) { + return val && val !== '0' ? val : ''; +} + export function buildAuthorTeaser(parentElement, author, isAuthorList = false) { // add updated link to all author articles const imageWrapper = document.createElement('div'); @@ -17,34 +21,34 @@ export function buildAuthorTeaser(parentElement, author, isAuthorList = false) { authorHeadingWrapper.classList.add('author-heading-wrapper'); const authorHeading = document.createElement('div'); authorHeading.classList.add('author-heading'); - authorHeading.innerHTML = `

${author.name}

${author['author-title']}

`; + authorHeading.innerHTML = `

${author.name}

${checkValue(author['author-title'])}

`; authorHeadingWrapper.append(authorHeading); authorDetails.append(authorHeadingWrapper); const authorDescription = document.createElement('p'); - authorDescription.append(author.intro); + authorDescription.append(checkValue(author.intro)); authorDetails.append(authorDescription); const socialLinks = document.createElement('ul'); - if (author.twitter) { + if (author.twitter && author.twitter !== '0') { const twitterLink = document.createElement('li'); twitterLink.innerHTML = ``; socialLinks.append(twitterLink); } - if (author.facebook) { + if (author.facebook && author.facebook !== '0') { const facebookLink = document.createElement('li'); facebookLink.innerHTML = ``; socialLinks.append(facebookLink); } - if (author.instagram) { + if (author.instagram && author.instagram !== '0') { const instagramLink = document.createElement('li'); instagramLink.innerHTML = ``; socialLinks.append(instagramLink); } - if (author.youtube) { + if (author.youtube && author.youtube !== '0') { const youtubeLink = document.createElement('li'); youtubeLink.innerHTML = ``; socialLinks.append(youtubeLink); } - if (author.pintrest) { + if (author.pintrest && author.pintrest !== '0') { const pintrestLink = document.createElement('li'); pintrestLink.innerHTML = ``; socialLinks.append(pintrestLink);