Skip to content

Commit

Permalink
dont render callout-content div if blank (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-dot-earth authored Jun 10, 2024
1 parent 1812845 commit c7e255d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <p> tag in it,
*/
if (content === "\n<p>\n") {
content = "";
}
let contentDiv = content ? `\n<div class="callout-content">${content}</div>` : "";

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<div class="callout-content">${content}</div>`;
blockquote.innerHTML = `${titleDiv}${contentDiv}`;
}
};

Expand Down

0 comments on commit c7e255d

Please sign in to comment.