Files
site-portfolio/scripts/gen-ai-dev-placeholders.mjs

32 lines
1.2 KiB
JavaScript

// Генерация серых заглушек (16:10) для страницы ai-dev.
// Заглушки — намеренно нейтральный серый, без текста и градиентов.
import fs from "node:fs";
import path from "node:path";
import sharp from "sharp";
const outDir = path.join(process.cwd(), "public", "assets", "ai-dev");
fs.mkdirSync(outDir, { recursive: true });
const W = 640;
const H = 400;
// Разные оттенки серого, чтобы карточки не выглядели одинаковыми при загрузке.
const shades = [
{ fill: "#2a2d31", label: "01" },
{ fill: "#31353a", label: "02" },
{ fill: "#25282c", label: "03" },
];
const tiles = await Promise.all(
shades.map(async ({ fill, label }) => {
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}">
<rect width="${W}" height="${H}" fill="${fill}" />
</svg>`;
const file = path.join(outDir, `placeholder-${label}.webp`);
await sharp(Buffer.from(svg)).webp({ quality: 72 }).toFile(file);
return file;
}),
);
console.log(`Generated ${tiles.length} placeholders in ${outDir}`);
for (const f of tiles) console.log(" ", path.basename(f), fs.statSync(f).size, "bytes");