Skip to content

Commit

Permalink
MWPW-144470 Remove author link from article header (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
meganthecoder committed Sep 17, 2024
1 parent 04c3cb0 commit ed687b9
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 ed687b9

Please sign in to comment.