Add enableLazyLoading parameter to figure element paired shortcode
This commit is contained in:
parent
a5b0567c8a
commit
832e1d07fd
|
@ -104,10 +104,10 @@ module.exports = function (eleventyConfig) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Paired shortcode: image figure and figcaption
|
// Paired shortcode: image figure and figcaption
|
||||||
eleventyConfig.addPairedShortcode('imgFigure', (caption, img, alt=caption) => {
|
eleventyConfig.addPairedShortcode('imgFigure', (caption, img, alt=caption, enableLazyLoading=true) => {
|
||||||
const figcaption = markdownLibrary.renderInline(caption);
|
const figcaption = markdownLibrary.renderInline(caption);
|
||||||
return `<figure>
|
return `<figure>
|
||||||
<img src="${img}" alt="${alt}">
|
<img src="${img}" alt="${alt}"${enableLazyLoading ? ' loading="lazy"' : ''}>
|
||||||
<figcaption>${figcaption}</figcaption>
|
<figcaption>${figcaption}</figcaption>
|
||||||
</figure>`;
|
</figure>`;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue