Update image references to use WebP format for improved performance and remove unused design candidates from the project. Adjusted placeholder image handling in the faculty import script and updated metadata for various pages to reflect the new image paths.

This commit is contained in:
smhk1376 committed 2026-10-16 17:45:55 +03:30
1 parent 5b0a394216
commit 05b0a1af72
94 files changed
+181 -36

No files matched your search

+3
View File
@@ -18,6 +18,9 @@
.claude .claude
skills skills
# unused design candidates (not referenced by the app)
/public/CandidatesIMages
# project meta / docs # project meta / docs
memory-bank memory-bank
docs docs
+5
View File
@@ -25,6 +25,11 @@ const nextConfig: NextConfig = {
destination: "https://mst.aut.ac.ir/content/31094/شبکه-اساتید", destination: "https://mst.aut.ac.ir/content/31094/شبکه-اساتید",
permanent: true, permanent: true,
}, },
{
source: "/images/faculty/placeholder.png",
destination: "/images/faculty/placeholder.webp",
permanent: true,
},
]; ];
}, },
}; };
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 232 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

+8 -6
View File
@@ -170,11 +170,13 @@ async function main() {
const publicFaculty = path.join(root, "public", "images", "faculty"); const publicFaculty = path.join(root, "public", "images", "faculty");
mkdirSync(publicFaculty, { recursive: true }); mkdirSync(publicFaculty, { recursive: true });
if (filesDir && existsSync(path.join(filesDir, "johndoe.png"))) { const destPlaceholder = path.join(publicFaculty, "placeholder.webp");
copyFileSync( if (
path.join(filesDir, "johndoe.png"), filesDir &&
path.join(publicFaculty, "placeholder.png"), existsSync(path.join(filesDir, "johndoe.png")) &&
); !existsSync(destPlaceholder)
) {
copyFileSync(path.join(filesDir, "johndoe.png"), destPlaceholder);
} }
const { Client } = pg; const { Client } = pg;
@@ -200,7 +202,7 @@ async function main() {
byName.get(p.name.replace(/\s+/g, " ").trim().toLowerCase()); byName.get(p.name.replace(/\s+/g, " ").trim().toLowerCase());
const id = match?.id ?? facultyId(p); const id = match?.id ?? facultyId(p);
let imageUrl = match?.image_url || "/images/faculty/placeholder.png"; let imageUrl = match?.image_url || "/images/faculty/placeholder.webp";
const fileBase = p.imageSrc.split(/[/\\]/).pop() || ""; const fileBase = p.imageSrc.split(/[/\\]/).pop() || "";
const isPlaceholder = const isPlaceholder =
!fileBase || !fileBase ||
+143
View File
@@ -0,0 +1,143 @@
/**
* Convert fixed static assets (brand/logos) to compact WebP.
* Skips course uploads, faculty photos (except placeholder), and favicon PNGs.
*/
import fs from "node:fs";
import path from "node:path";
import sharp from "sharp";
const ROOT = process.cwd();
const SKIP_DIR_PARTS = [
path.join("public", "images", "courses"),
path.join("public", "brand", "icons"),
];
const SKIP_FILES = new Set(
[
"public/icon-192.png",
"public/icon-512.png",
"public/apple-touch-icon.png",
"src/app/icon.png",
"src/app/apple-icon.png",
].map((p) => path.normalize(p)),
);
const LOGO_NAMES = new Set([
"mst-faculty.png",
"mst-faculty-icon.png",
"mst-faculty-full-with-text.png",
"MstAutIcon_horizontal.png",
"MstAutIcon.png",
"logo_fa.png",
"logo_fa_w.png",
"amirkabir.png",
"amirkabir-black-bg.png",
]);
function walk(dir, acc = []) {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const full = path.join(dir, entry.name);
if (entry.isDirectory()) walk(full, acc);
else if (/\.(png|jpe?g)$/i.test(entry.name)) acc.push(full);
}
return acc;
}
function shouldSkip(abs) {
const rel = path.relative(ROOT, abs);
const norm = path.normalize(rel);
if (SKIP_FILES.has(norm)) return true;
if (SKIP_DIR_PARTS.some((d) => norm.startsWith(d))) return true;
// Faculty photos from admin/sync — keep. Convert only the fixed placeholder.
if (norm.startsWith(path.join("public", "images", "faculty"))) {
return path.basename(norm) !== "placeholder.png";
}
return false;
}
function presetFor(rel, meta) {
const base = path.basename(rel);
const isLogo = LOGO_NAMES.has(base);
const isHorizontal = base === "MstAutIcon_horizontal.png";
const isPlaceholder = base === "placeholder.png";
if (isHorizontal) {
return { lossless: true };
}
if (isLogo) {
return { lossless: true };
}
if (isPlaceholder) {
return { maxEdge: 640, quality: 58, alphaQuality: 70 };
}
// Decorative / hero illustrations (often under overlays)
return { maxEdge: 1080, quality: 48, alphaQuality: 65 };
}
function destPath(abs) {
return abs.replace(/\.(png|jpe?g)$/i, ".webp");
}
const candidates = [
...walk(path.join(ROOT, "public", "brand")),
...walk(path.join(ROOT, "public", "CandidatesIMages")),
path.join(ROOT, "public", "MstAutIcon_horizontal.png"),
path.join(ROOT, "public", "MstAutIcon.png"),
path.join(ROOT, "public", "images", "faculty", "placeholder.png"),
].filter((f) => fs.existsSync(f) && !shouldSkip(f));
let before = 0;
let after = 0;
for (const abs of candidates) {
const rel = path.relative(ROOT, abs);
const srcSize = fs.statSync(abs).size;
before += srcSize;
const img = sharp(abs);
const meta = await img.metadata();
const cfg = presetFor(rel, meta);
let pipeline = img;
const w = meta.width ?? 0;
const h = meta.height ?? 0;
if (cfg.maxHeight && h > cfg.maxHeight) {
pipeline = pipeline.resize({ height: cfg.maxHeight, withoutEnlargement: true });
} else if (cfg.maxEdge) {
const edge = Math.max(w, h);
if (edge > cfg.maxEdge) {
pipeline = pipeline.resize({
width: w >= h ? cfg.maxEdge : undefined,
height: h > w ? cfg.maxEdge : undefined,
withoutEnlargement: true,
});
}
}
const out = destPath(abs);
await pipeline
.webp(
cfg.lossless
? { lossless: true, effort: 6 }
: {
quality: cfg.quality,
alphaQuality: cfg.alphaQuality,
effort: 6,
smartSubsample: true,
},
)
.toFile(out);
const outSize = fs.statSync(out).size;
after += outSize;
fs.unlinkSync(abs);
const pct = ((1 - outSize / srcSize) * 100).toFixed(0);
console.log(
`${(srcSize / 1024).toFixed(0).padStart(6)}KB → ${(outSize / 1024).toFixed(0).padStart(5)}KB (-${pct}%) ${rel}`,
);
}
console.log(
`\nTOTAL ${(before / 1024 / 1024).toFixed(2)} MB → ${(after / 1024 / 1024).toFixed(2)} MB (${candidates.length} files)`,
);
+1 -1
View File
@@ -28,7 +28,7 @@ export default async function AlumniPage() {
<PageHero <PageHero
title={t("alumniTitle")} title={t("alumniTitle")}
intro={t("alumniIntro")} intro={t("alumniIntro")}
imageUrl="/brand/graduation-cap-neural.png" imageUrl="/brand/graduation-cap-neural.webp"
/> />
<Section tone="subtle"> <Section tone="subtle">
<Container> <Container>
+1 -1
View File
@@ -25,7 +25,7 @@ export default async function InsightsPage() {
<PageHero <PageHero
title={t("insightsTitle")} title={t("insightsTitle")}
intro={t("insightsIntro")} intro={t("insightsIntro")}
imageUrl="/brand/neural-open-book.png" imageUrl="/brand/neural-open-book.webp"
/> />
<Section tone="subtle"> <Section tone="subtle">
<Container> <Container>
+1 -1
View File
@@ -34,7 +34,7 @@ export default async function ProgramsPage() {
<PageHero <PageHero
title={t("programsTitle")} title={t("programsTitle")}
intro={t("programsIntro")} intro={t("programsIntro")}
imageUrl="/brand/neural-tree-knowledge.png" imageUrl="/brand/neural-tree-knowledge.webp"
/> />
<Section tone="subtle"> <Section tone="subtle">
<Container className="space-y-16"> <Container className="space-y-16">
+1 -1
View File
@@ -29,7 +29,7 @@ export default async function ValuesPage() {
eyebrow={valuesContent.eyebrow} eyebrow={valuesContent.eyebrow}
title={valuesContent.title} title={valuesContent.title}
intro={valuesContent.intro} intro={valuesContent.intro}
imageUrl="/brand/collective-intelligence.png" imageUrl="/brand/collective-intelligence.webp"
/> />
<Section tone="subtle"> <Section tone="subtle">
+1 -1
View File
@@ -54,7 +54,7 @@ export async function generateMetadata(): Promise<Metadata> {
title: t("homeTitle"), title: t("homeTitle"),
description: t("homeDescription"), description: t("homeDescription"),
images: [ images: [
{ url: "/brand/mst-faculty.png", alt: "دانشکده مدیریت، علم و فناوری دانشگاه صنعتی امیرکبیر" }, { url: "/brand/mst-faculty.webp", alt: "دانشکده مدیریت، علم و فناوری دانشگاه صنعتی امیرکبیر" },
], ],
}, },
twitter: { twitter: {
+1 -1
View File
@@ -56,7 +56,7 @@ function LoginForm() {
<CardHeader className="space-y-3 text-center"> <CardHeader className="space-y-3 text-center">
<div className="mx-auto relative size-14"> <div className="mx-auto relative size-14">
<Image <Image
src="/brand/mst-faculty.png" src="/brand/mst-faculty.webp"
alt="دانشگاه صنعتی امیرکبیر" alt="دانشگاه صنعتی امیرکبیر"
fill fill
sizes="56px" sizes="56px"
+2 -2
View File
@@ -3,9 +3,9 @@ import Link from "next/link";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
/** Faculty seal mark (transparent). Source: MST icon with side text removed. */ /** Faculty seal mark (transparent). Source: MST icon with side text removed. */
const MARK_SRC = "/brand/mst-faculty.png"; const MARK_SRC = "/brand/mst-faculty.webp";
/** Horizontal wordmark with faculty + university name baked in. */ /** Horizontal wordmark with faculty + university name baked in. */
const HORIZONTAL_SRC = "/MstAutIcon_horizontal.png"; const HORIZONTAL_SRC = "/MstAutIcon_horizontal.webp";
type BrandLogoProps = { type BrandLogoProps = {
href?: string; href?: string;
+1 -1
View File
@@ -24,7 +24,7 @@ export function HeroFeatured({
<header className="home-hero relative isolate overflow-hidden bg-primary text-primary-foreground"> <header className="home-hero relative isolate overflow-hidden bg-primary text-primary-foreground">
<div className="pointer-events-none absolute inset-0 z-[1]" aria-hidden> <div className="pointer-events-none absolute inset-0 z-[1]" aria-hidden>
<Image <Image
src="/brand/amirkabir-arches.png" src="/brand/amirkabir-arches.webp"
alt="" alt=""
fill fill
priority priority
+1 -1
View File
@@ -34,7 +34,7 @@ export function PageHero({
)} )}
> >
<Image <Image
src={imageUrl ?? "/brand/neural-learning-wave.png"} src={imageUrl ?? "/brand/neural-learning-wave.webp"}
alt="" alt=""
fill fill
priority priority
@@ -37,7 +37,7 @@ export function AdminShell({
<div className="flex min-w-0 items-center gap-2"> <div className="flex min-w-0 items-center gap-2">
<span className="relative size-6 shrink-0 md:hidden"> <span className="relative size-6 shrink-0 md:hidden">
<Image <Image
src="/brand/mst-faculty.png" src="/brand/mst-faculty.webp"
alt="" alt=""
fill fill
sizes="24px" sizes="24px"
@@ -110,7 +110,7 @@ export function AdminSidebar({ userName }: { userName: string }) {
> >
<span className="relative size-8 shrink-0"> <span className="relative size-8 shrink-0">
<Image <Image
src="/brand/mst-faculty.png" src="/brand/mst-faculty.webp"
alt="" alt=""
fill fill
sizes="32px" sizes="32px"
+2 -2
View File
@@ -36,7 +36,7 @@ export function AboutTemplate({ topics }: { topics: IntersectionTopic[] }) {
eyebrow={aboutContent.eyebrow} eyebrow={aboutContent.eyebrow}
title={aboutContent.title} title={aboutContent.title}
intro={aboutContent.intro} intro={aboutContent.intro}
imageUrl="/brand/university-emblem-neural.png" imageUrl="/brand/university-emblem-neural.webp"
/> />
<Section tone="subtle"> <Section tone="subtle">
@@ -59,7 +59,7 @@ export function AboutTemplate({ topics }: { topics: IntersectionTopic[] }) {
<div className="grid min-w-0 items-center gap-10 lg:grid-cols-2 lg:gap-14"> <div className="grid min-w-0 items-center gap-10 lg:grid-cols-2 lg:gap-14">
<div className="relative order-1 aspect-[16/10] overflow-hidden rounded-2xl bg-primary lg:order-none"> <div className="relative order-1 aspect-[16/10] overflow-hidden rounded-2xl bg-primary lg:order-none">
<Image <Image
src="/brand/ai-learning-frames.png" src="/brand/ai-learning-frames.webp"
alt="یادگیری مبتنی بر هوش مصنوعی و چارچوب های دانشگاهی" alt="یادگیری مبتنی بر هوش مصنوعی و چارچوب های دانشگاهی"
fill fill
className="object-cover object-center" className="object-cover object-center"
+1 -1
View File
@@ -215,7 +215,7 @@ export function HomeApproach() {
</div> </div>
<div className="relative order-1 aspect-[16/10] min-h-0 lg:order-2 lg:aspect-auto lg:min-h-full lg:self-stretch"> <div className="relative order-1 aspect-[16/10] min-h-0 lg:order-2 lg:aspect-auto lg:min-h-full lg:self-stretch">
<Image <Image
src="/brand/campus-collaboration-v1.png" src="/brand/campus-collaboration-v1.webp"
alt="رویکرد آموزشی مرکز آموزش های آزاد" alt="رویکرد آموزشی مرکز آموزش های آزاد"
fill fill
className="object-cover" className="object-cover"
@@ -61,7 +61,7 @@ export function ProfessionalLandingTemplate({
eyebrow={labels.offeredBy} eyebrow={labels.offeredBy}
title={labels.heroTitle} title={labels.heroTitle}
intro={labels.heroBody} intro={labels.heroBody}
imageUrl="/brand/executive-seminar-neural.png" imageUrl="/brand/executive-seminar-neural.webp"
actions={ actions={
<DotCta href="#programs" onDark> <DotCta href="#programs" onDark>
{labels.exploreCourses} {labels.exploreCourses}
@@ -105,7 +105,7 @@ export function ProfessionalLandingTemplate({
> >
<div className="pointer-events-none absolute inset-0" aria-hidden> <div className="pointer-events-none absolute inset-0" aria-hidden>
<Image <Image
src="/brand/ai-learning-frames.png" src="/brand/ai-learning-frames.webp"
alt="" alt=""
fill fill
className="object-cover object-[60%_45%] opacity-25 mix-blend-screen" className="object-cover object-[60%_45%] opacity-25 mix-blend-screen"
+2 -2
View File
@@ -13,7 +13,7 @@ import {
type ParsedMstFaculty, type ParsedMstFaculty,
} from "@/lib/faculty/parse-mst-network"; } from "@/lib/faculty/parse-mst-network";
const PLACEHOLDER_IMAGE = "/images/faculty/placeholder.png"; const PLACEHOLDER_IMAGE = "/images/faculty/placeholder.webp";
const FETCH_TIMEOUT_MS = 25_000; const FETCH_TIMEOUT_MS = 25_000;
export type FacultySyncResult = { export type FacultySyncResult = {
@@ -126,7 +126,7 @@ async function resolveImageUrl(
if (opts.localImageDir && isPlaceholderSrc(src)) { if (opts.localImageDir && isPlaceholderSrc(src)) {
const from = path.join(opts.localImageDir, "johndoe.png"); const from = path.join(opts.localImageDir, "johndoe.png");
const dest = path.join(facultyDir, "placeholder.png"); const dest = path.join(facultyDir, "placeholder.webp");
if (!(await fileExists(dest)) && (await fileExists(from))) { if (!(await fileExists(dest)) && (await fileExists(from))) {
await copyFile(from, dest); await copyFile(from, dest);
} }
+1 -5
View File
@@ -27,11 +27,7 @@ export const siteAddress = {
phone: "۰۲۱-۶۴۵۴۵۸۵۸", phone: "۰۲۱-۶۴۵۴۵۸۵۸",
phoneTel: "+982164545858", phoneTel: "+982164545858",
email: "mst@aut.ac.ir", email: "mst@aut.ac.ir",
mapUrl: mapUrl: "https://maps.app.goo.gl/RKKhZvN6cLYsmrKa8",
"https://maps.google.com/?q=" +
encodeURIComponent(
"تهران، خیابان انقلاب غرب، کوچه سعید، بن‌بست نائینی، ساختمان زکریای رازی",
),
}; };
/** Main nav labels for Persian users (seed/reference — runtime uses site-config + course-nav). */ /** Main nav labels for Persian users (seed/reference — runtime uses site-config + course-nav). */
+1 -1
View File
@@ -30,7 +30,7 @@ export function pageMetadata(opts: {
absoluteTitle?: boolean; absoluteTitle?: boolean;
}): Metadata { }): Metadata {
const path = opts.path.startsWith("/") ? opts.path : `/${opts.path}`; const path = opts.path.startsWith("/") ? opts.path : `/${opts.path}`;
const image = opts.image ?? "/brand/mst-faculty.png"; const image = opts.image ?? "/brand/mst-faculty.webp";
return { return {
title: opts.absoluteTitle ? { absolute: opts.title } : opts.title, title: opts.absoluteTitle ? { absolute: opts.title } : opts.title,
description: opts.description, description: opts.description,
+1 -5
View File
@@ -93,11 +93,7 @@ export const siteAddress = {
/** ASCII for tel: / schema */ /** ASCII for tel: / schema */
phoneTel: "+982164545858", phoneTel: "+982164545858",
email: "mst@aut.ac.ir", email: "mst@aut.ac.ir",
mapUrl: mapUrl: "https://maps.app.goo.gl/RKKhZvN6cLYsmrKa8",
"https://maps.google.com/?q=" +
encodeURIComponent(
"تهران، خیابان انقلاب غرب، کوچه سعید، بن‌بست نائینی، ساختمان زکریای رازی",
),
}; };
/** /**