Skip to content

Commit

Permalink
Fix Author Teaser (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
bstopp authored Apr 16, 2024
1 parent 0b35745 commit 2e5fcaf
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cigaradvisor/blocks/author-teaser/author-teaser.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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 = `<h2 class="author-name">${author.name}</h2><h3 class="author-title">${author['author-title']}</h3>`;
authorHeading.innerHTML = `<h2 class="author-name">${author.name}</h2><h3 class="author-title">${checkValue(author['author-title'])}</h3>`;
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 = `<a href="https://twitter.com/${author.twitter}" target="_blank" rel="noopener noreferrer"><span class="icon icon-x-twitter"></span></a>`;
socialLinks.append(twitterLink);
}
if (author.facebook) {
if (author.facebook && author.facebook !== '0') {
const facebookLink = document.createElement('li');
facebookLink.innerHTML = `<a href="https://facebook.com/${author.facebook}" target="_blank" rel="noopener noreferrer"><span class="icon icon-facebook-f"></span></a>`;
socialLinks.append(facebookLink);
}
if (author.instagram) {
if (author.instagram && author.instagram !== '0') {
const instagramLink = document.createElement('li');
instagramLink.innerHTML = `<a href="https://instagram.com/${author.instagram}" target="_blank" rel="noopener noreferrer"><span class="icon icon-instagram"></span></a>`;
socialLinks.append(instagramLink);
}
if (author.youtube) {
if (author.youtube && author.youtube !== '0') {
const youtubeLink = document.createElement('li');
youtubeLink.innerHTML = `<a href="https://youtube.com/${author.youtube}" target="_blank" rel="noopener noreferrer"><span class="icon icon-youtube"></span></a>`;
socialLinks.append(youtubeLink);
}
if (author.pintrest) {
if (author.pintrest && author.pintrest !== '0') {
const pintrestLink = document.createElement('li');
pintrestLink.innerHTML = `<a href="https://pintrest.com/${author.pintrest}" target="_blank" rel="noopener noreferrer"><span class="icon icon-pintrest-p"></span></a>`;
socialLinks.append(pintrestLink);
Expand Down

0 comments on commit 2e5fcaf

Please sign in to comment.