Add class name parameter to image figures

This commit is contained in:
Helen Chong 2024-07-31 00:03:46 +08:00
parent d3f9750ab7
commit 0c7462ea48
1 changed files with 5 additions and 2 deletions

View File

@ -21,9 +21,12 @@ export default function(eleventyConfig) {
});
// Image figure and figcaption
eleventyConfig.addPairedShortcode('imgFigure', (caption, img, alt=caption, enableLazyLoading=true) => {
eleventyConfig.addPairedShortcode('imgFigure', (
caption, img, alt=caption, className, enableLazyLoading=true
) => {
const classMarkup = className ? ` class="${className}"` : "";
const figcaption = markdownLibrary.renderInline(caption);
return `<figure>
return `<figure${classMarkup}>
<img src="${img}" alt="${alt}"${enableLazyLoading ? ' loading="lazy"' : ''}>
<figcaption>${figcaption}</figcaption>
</figure>`;