mirror of
https://github.com/tcsenpai/obsidiangarden_netlify.git
synced 2025-06-04 12:00:02 +00:00
dont render callout-content div if blank (#267)
This commit is contained in:
parent
18128453ef
commit
c7e255d202
15
.eleventy.js
15
.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 <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}`;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user