feat: servir les images via le CDN BunnyCDN
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
const cdn = require("./src/_data/cdn.json");
|
||||
|
||||
module.exports = function(eleventyConfig) {
|
||||
// Locale-aware content: `t` resolves to the content bundle for the page's locale (fr by default)
|
||||
eleventyConfig.addGlobalData("eleventyComputed", {
|
||||
@@ -5,6 +7,12 @@ module.exports = function(eleventyConfig) {
|
||||
t: (data) => data.i18n[data.locale || "fr"]
|
||||
});
|
||||
|
||||
// Serve local images through the BunnyCDN pull zone; leaves external URLs untouched
|
||||
eleventyConfig.addFilter("cdn", (path) => {
|
||||
if (typeof path !== "string" || !path.startsWith("/")) return path;
|
||||
return cdn.url + path;
|
||||
});
|
||||
|
||||
// Copy assets folders to output
|
||||
eleventyConfig.addPassthroughCopy("src/assets");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user