Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-144470 Remove author link from article header #65

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading