(async() => {
    const siteDomain = "blog.cybershell.xyz";
    const sharp = require('sharp');
    const fs = require('fs');
    const path = require('path');
    // const iconDir = path.join(__dirname, siteDomain);
    const siteImagesDir = path.join(__dirname, 'client', 'img');
    const siteIconDir = path.join(siteImagesDir, 'icon', siteDomain)
    const sourceIconFile = 'thumbnail.png';
    const sourceIconFilePath = path.join(__dirname, sourceIconFile);
    const sizes = [16, 32, 36, 48, 57, 60, 70, 72, 76, 96, 114, 120, 144, 150, 152, 180, 192, 256, 310, 384, 512];

    await fs.promises.mkdir(siteIconDir, { force: true, recursive: true });
    for (var size of sizes) {
        await sharp(sourceIconFilePath).resize({
            fit: sharp.fit.contain,
            width: size,
            height: size
        }).png()
            .toFile(path.join(siteIconDir, `icon-${size}x${size}.png`));
    }

    // await fs.promises.cp(sourceIconFilePath, path.join(siteIconDir, `${siteDomain}.png`));
    await fs.promises.cp(sourceIconFilePath, path.join(siteImagesDir, 'social-cards', `${siteDomain}.png`));
    // await fs.promises.cp(iconDir, path.join(siteImagesDir, 'icon' ), { recursive: true });
})()