diff --git a/_config/relative-links.js b/_config/relative-links.js index ee6cd4a..d119e6e 100644 --- a/_config/relative-links.js +++ b/_config/relative-links.js @@ -56,4 +56,19 @@ export default function (eleventyConfig) { priority: -1, // run last last (after PathToUrl) }, ); + + eleventyConfig.addTransform('relative-svg', function(content) { + if (!(this.page.outputPath || '').endsWith('.html')) { + return content; + } + const fromDir = this.url.endsWith("/") ? this.url : path.dirname(this.url); + + return content.replaceAll(/ { + let relativePath = path.relative(fromDir, matchedUrl); + if (!relativePath.startsWith(".")) { + relativePath = "./" + relativePath; + } + return `