fix: check if paragraph exists before accessing it's textContent

closes https://github.com/CaiJimmy/hugo-theme-stack/issues/490
This commit is contained in:
Jimmy Cai 2022-02-12 13:23:38 +00:00 committed by GitHub
parent 4b0dbb4630
commit 0fbbc12949

View file

@ -67,6 +67,8 @@ class StackGallery {
/// This is done to allow inline images within paragraphs
const paragraph = img.closest('p');
if (!paragraph || !container.contains(paragraph)) continue;
if (paragraph.textContent.trim() == '') {
/// Once we insert figcaption, this check no longer works
/// So we add a class to paragraph to mark it