From c7e255d2023bb4a1c320efd9f8e907b9e8aedc28 Mon Sep 17 00:00:00 2001 From: Tyler Nieman Date: Mon, 10 Jun 2024 12:14:39 -0700 Subject: [PATCH] dont render callout-content div if blank (#267) --- .eleventy.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.eleventy.js b/.eleventy.js index ef41c1e..0d9b5b0 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -381,13 +381,26 @@ module.exports = function (eleventyConfig) { } ); + /* Hacky fix for callouts with only a title: + This will ensure callout-content isn't produced if + the callout only has a title, like this: + ```md + > [!info] i only have a title + ``` + Not sure why content has a random

tag in it, + */ + if (content === "\n

\n") { + content = ""; + } + let contentDiv = content ? `\n

${content}
` : ""; + blockquote.tagName = "div"; blockquote.classList.add("callout"); blockquote.classList.add(isCollapsable ? "is-collapsible" : ""); blockquote.classList.add(isCollapsed ? "is-collapsed" : ""); blockquote.setAttribute("data-callout", calloutType.toLowerCase()); calloutMetaData && blockquote.setAttribute("data-callout-metadata", calloutMetaData); - blockquote.innerHTML = `${titleDiv}\n
${content}
`; + blockquote.innerHTML = `${titleDiv}${contentDiv}`; } };