This commit is contained in:
parent
14c5d7d61c
commit
34ef76515c
1 changed files with 15 additions and 0 deletions
|
@ -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(/<use href="([^"]*)"/g, (_, matchedUrl) => {
|
||||
let relativePath = path.relative(fromDir, matchedUrl);
|
||||
if (!relativePath.startsWith(".")) {
|
||||
relativePath = "./" + relativePath;
|
||||
}
|
||||
return `<use href="${relativePath}"`;
|
||||
});
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue