add favicon

for some reason it seems to be broken in `npm run start`...
This commit is contained in:
Lyn Fugmann 2024-10-02 18:18:54 +02:00
parent db6c994758
commit db6ed12ba2
5 changed files with 94 additions and 2 deletions

View file

@ -1,5 +1,6 @@
const { EleventyHtmlBasePlugin, EleventyI18nPlugin } = require("@11ty/eleventy");
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
const faviconsPlugin = require("eleventy-plugin-gen-favicons");
const bundlerPlugin = require("@11ty/eleventy-plugin-bundle");
const pluginIcons = require('eleventy-plugin-icons');
const Image = require("@11ty/eleventy-img");
@ -24,6 +25,7 @@ module.exports = function(eleventyConfig) {
shortcode: "rawIcon",
},
});
eleventyConfig.addPlugin(faviconsPlugin, {});
// override icon shortcode to make the SVGs accessible
eleventyConfig.addAsyncShortcode("icon", async function(input, attrs) {
@ -81,7 +83,13 @@ module.exports = function(eleventyConfig) {
});
await session.replaceAll();
return session.getSvgString();
let finalSvg = session.getSvgString();
// no idea why this gets mangled
finalSvg = finalSvg.replaceAll("svg:svg", "svg");
finalSvg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' + finalSvg;
return finalSvg;
};
}
});
@ -130,7 +138,7 @@ module.exports = function(eleventyConfig) {
async ({ dir, runMode, outputMode }) => {
if (outputMode === "fs") {
fs.copyFile(`${dir.output}/de/index.html`, `${dir.output}/index.html`, (err) => {
if (err) console.log(err);
if (err && err.code !== 'ENOENT') console.log(err);
});
}
}