Skip to content

Commit

Permalink
Show Outline headline only if outline content exists (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert authored Oct 10, 2023
1 parent cf273f5 commit 8e670a7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion blocks/talk-detail-before-outline/talk-detail-before-outline.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ function buildVideo(parent) {
loadBlocks(parent);
}

/**
* @returns true if any "p" or "li" element is found in the default content.
*/
function isOutlinePresent() {
return document.querySelectorAll('main .default-content-wrapper p, main .default-content-wrapper li').length > 0;
}

/**
* Talk detail before outline: Tags, time info and video.
* @param {Element} block
Expand All @@ -75,5 +82,7 @@ export default async function decorate(block) {
buildTimeInfo(block, scheduleEntry);
}
buildVideo(block);
append(block, 'h4').textContent = 'Outline';
if (isOutlinePresent()) {
append(block, 'h4').textContent = 'Outline';
}
}

0 comments on commit 8e670a7

Please sign in to comment.