Remove empty <p> tags before and after accordions when paired together in shortcodes

This commit is contained in:
Helen Chong 2024-05-07 09:50:08 +08:00
parent f6aadf4b8e
commit abe5e13898
1 changed files with 3 additions and 4 deletions

View File

@ -81,14 +81,13 @@ module.exports = function (eleventyConfig) {
// Paired shorcode: Spoiler accordion // Paired shorcode: Spoiler accordion
eleventyConfig.addPairedShortcode('spoiler', (content, hint) => { eleventyConfig.addPairedShortcode('spoiler', (content, hint) => {
content = content.trim();
const hintMarkUp = markdownLibrary.renderInline(hint); const hintMarkUp = markdownLibrary.renderInline(hint);
const contentMarkup = markdownLibrary.render(content); const contentMarkup = markdownLibrary.render(content);
return ` return `<details class="spoiler-accordion">
<details class="spoiler-accordion">
<summary class="spoiler-accordion__hint">${hintMarkUp}</summary> <summary class="spoiler-accordion__hint">${hintMarkUp}</summary>
<div class="spoiler-accordion__spoiler">${contentMarkup}</div> <div class="spoiler-accordion__spoiler">${contentMarkup}</div>
</details> </details>`;
`;
}); });
/* This is the part that tells 11ty to swap to our custom config */ /* This is the part that tells 11ty to swap to our custom config */