-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsocialPreviewImages.js
More file actions
26 lines (25 loc) · 1.02 KB
/
Copy pathsocialPreviewImages.js
File metadata and controls
26 lines (25 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const fs = require("fs");
const Image = require("@11ty/eleventy-img");
const {yellow} = require("kleur");
module.exports = function () {
const socialPreviewImagesDir = "dist/images/social-preview-images/";
fs.readdir(socialPreviewImagesDir, (err, files) => {
if (!!files && files.length > 0) {
files.forEach(fileName => {
if (fileName.endsWith(".svg")) {
let imageUrl = socialPreviewImagesDir + fileName;
Image(imageUrl, {
formats: ["jpeg"],
outputDir: "./" + socialPreviewImagesDir,
filenameFormat: function (id, src, width, format, options) {
let outputFileName = fileName.substring(0, fileName.length - 4);
return `${outputFileName}.${format}`;
}
});
}
});
} else {
console.log(yellow("⚠ No social images found"));
}
});
};