Skip to content

Commit

Permalink
Merge pull request #67 from adobecom/stage
Browse files Browse the repository at this point in the history
[Release] Stage to Main
  • Loading branch information
meganthecoder authored Sep 17, 2024
2 parents da370b7 + e9380f5 commit 206603c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions blog/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ function buildBlock(blockName, content) {
function getImageCaption(picture) {
// Check if the parent element has a caption
const parentEl = picture.parentNode;
let caption = parentEl.querySelector('em');
const caption = parentEl.querySelector('em');
if (caption) return caption;

// If the parent element doesn't have a caption, check if the next sibling does
const parentSiblingEl = parentEl.nextElementSibling;
if (!parentSiblingEl || !parentSiblingEl.querySelector('picture')) return '';
const firstChildEl = parentSiblingEl.firstChild;
if (firstChildEl?.tagName === 'EM') return firstChildEl;
return '';
}

async function buildArticleHeader(el) {
Expand All @@ -90,7 +91,7 @@ async function buildArticleHeader(el) {
const articleHeaderBlockEl = buildBlock('article-header', [
['<p></p>'],
[h1],
[`<p>${authorURL ? `<a href="${authorURL}">${author}</a>` : author}</p>
[`<p><span ${authorURL ? `data-author-page="${authorURL}"` : ''}>${author}</span></p>
<p>${publicationDate}</p>`],
[figure],
]);
Expand Down

0 comments on commit 206603c

Please sign in to comment.