Update Site source

This commit is contained in:
Meghdad committed 2026-10-13 00:25:42 +03:30
1 parent 80a257835f
commit 783bcf2dd8
15 files changed
+48 -41

No files matched your search

+3 -8
View File
@@ -1,15 +1,10 @@
import fs from 'node:fs/promises';
import opentype from '@shuding/opentype.js';
import sharp from 'sharp';
const fontBytes=await fs.readFile(new URL('../lib/fonts/Vazirmatn-Bold.ttf',import.meta.url));
const font=opentype.parse(fontBytes.buffer.slice(fontBytes.byteOffset,fontBytes.byteOffset+fontBytes.byteLength));
const glyph=font.getPath('س',0,0,64);
const xs=glyph.commands.flatMap(c=>[c.x,c.x1,c.x2].filter(Number.isFinite));const ys=glyph.commands.flatMap(c=>[c.y,c.y1,c.y2].filter(Number.isFinite));
const box={x1:Math.min(...xs),x2:Math.max(...xs),y1:Math.min(...ys),y2:Math.max(...ys)};const scale=Math.min(34/(box.x2-box.x1),27/(box.y2-box.y1));
const dx=32-(box.x1+box.x2)/2*scale,dy=34-(box.y1+box.y2)/2*scale;
const svg=`<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>نشان خزانه سایفوند انرژی</title><rect width="64" height="64" rx="14" fill="#141618"/><path d="M14 13h36v24c0 10-8 16-18 21-10-5-18-11-18-21V13Z" fill="#30291d" stroke="#d1ab6c" stroke-width="3" stroke-linejoin="round"/><g transform="translate(${dx.toFixed(3)} ${dy.toFixed(3)}) scale(${scale.toFixed(5)})"><path d="${glyph.toPathData(3)}" fill="#f1cd8d"/></g></svg>`;
import {energyArt} from '../lib/energy-art.mjs';
const svg=energyArt;
const publicDir=new URL('../public/',import.meta.url);
await fs.writeFile(new URL('favicon.svg',publicDir),svg);
await fs.writeFile(new URL('siphoned-energy.svg',publicDir),svg);
await sharp(Buffer.from(svg)).resize(32,32).png().toFile(new URL('favicon-32.png',publicDir).pathname);
await sharp(Buffer.from(svg)).resize(180,180).png().toFile(new URL('apple-touch-icon.png',publicDir).pathname);
const sizes=[16,32,48];const pngs=await Promise.all(sizes.map(size=>sharp(Buffer.from(svg)).resize(size,size).png().toBuffer()));