Add class name parameter to image figures
This commit is contained in:
parent
d3f9750ab7
commit
0c7462ea48
|
@ -21,9 +21,12 @@ export default function(eleventyConfig) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Image figure and figcaption
|
// 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);
|
const figcaption = markdownLibrary.renderInline(caption);
|
||||||
return `<figure>
|
return `<figure${classMarkup}>
|
||||||
<img src="${img}" alt="${alt}"${enableLazyLoading ? ' loading="lazy"' : ''}>
|
<img src="${img}" alt="${alt}"${enableLazyLoading ? ' loading="lazy"' : ''}>
|
||||||
<figcaption>${figcaption}</figcaption>
|
<figcaption>${figcaption}</figcaption>
|
||||||
</figure>`;
|
</figure>`;
|
||||||
|
|
Loading…
Reference in New Issue