Implement dynamic font size adjustment for captions

Add script to adjust font size of enclosure captions based on article body font size.
This commit is contained in:
Justin Reeves authored and GitHub committed 2026-11-11 19:29:06 -06:00
1 parent 9816279850
commit bb78080f1f
1 file changed
+12 -1
+12 -1
View File
@@ -14,4 +14,15 @@
[[primary_media]]
<div id="bodyContainer" class="articleBody [[text_size_class]]">[[body]]</div>
[[enclosures]]
</article>
</article>
<script>
document.addEventListener("DOMContentLoaded", () => {
const articleBody = document.querySelector(".articleBody");
const textSize = parseFloat(getComputedStyle(articleBody).fontSize);
document.querySelectorAll(".nnw-enclosure-caption").forEach(enclosureCaption => {
enclosureCaption.style.fontSize = `${textSize - 2}px`;
});
});
</script>