diff --git a/eleventy.config.js b/eleventy.config.js index 7ec5766..a9607dd 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -26,15 +26,18 @@ module.exports = function(eleventyConfig) { // override icon shortcode to make the SVGs accessible eleventyConfig.addAsyncShortcode("icon", async function(input, attrs) { + let out; if (!attrs || !("title" in attrs)) { - return eleventyConfig.nunjucksAsyncShortcodes.rawIcon(input, attrs); + out = await eleventyConfig.nunjucksAsyncShortcodes.rawIcon(input, attrs); + } else { + const { title, ...newAttrs } = attrs; + newAttrs.role = "img"; + const svgStr = await eleventyConfig.nunjucksAsyncShortcodes.rawIcon(input, newAttrs); + const match = svgStr.match(/()(.*$)/s); + out = match[1] + "" + title + "" + match[2]; } - - const { title, ...newAttrs } = attrs; - newAttrs.role = "img"; - const svgStr = await eleventyConfig.nunjucksAsyncShortcodes.rawIcon(input, newAttrs); - const match = svgStr.match(/()(.*$)/s); - return match[1] + "" + title + "" + match[2]; + // line breaks cause some issues + return out.replaceAll("\n", ""); }); // process the logo files