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.
No files matched your search
@@ -18,6 +18,9 @@
|
||||
.claude
|
||||
skills
|
||||
|
||||
# unused design candidates (not referenced by the app)
|
||||
/public/CandidatesIMages
|
||||
|
||||
# project meta / docs
|
||||
memory-bank
|
||||
docs
|
||||
|
||||
@@ -25,6 +25,11 @@ const nextConfig: NextConfig = {
|
||||
destination: "https://mst.aut.ac.ir/content/31094/شبکه-اساتید",
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/images/faculty/placeholder.png",
|
||||
destination: "/images/faculty/placeholder.webp",
|
||||
permanent: true,
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 MiB |
|
After Width: | Height: | Size: 181 KiB |
|
Before Width: | Height: | Size: 1.8 MiB |
|
After Width: | Height: | Size: 230 KiB |
|
Before Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 2.9 MiB |
|
After Width: | Height: | Size: 430 KiB |
|
Before Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 158 KiB |
|
Before Width: | Height: | Size: 2.2 MiB |
|
After Width: | Height: | Size: 276 KiB |
|
Before Width: | Height: | Size: 2.6 MiB |
|
After Width: | Height: | Size: 324 KiB |
|
Before Width: | Height: | Size: 2.3 MiB |
|
After Width: | Height: | Size: 296 KiB |
|
Before Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 258 KiB |
|
Before Width: | Height: | Size: 1.5 MiB |
|
After Width: | Height: | Size: 153 KiB |
|
Before Width: | Height: | Size: 2.7 MiB |
|
After Width: | Height: | Size: 255 KiB |
|
Before Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 276 KiB |
|
Before Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 232 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 1.5 MiB |
|
After Width: | Height: | Size: 153 KiB |
|
Before Width: | Height: | Size: 1.8 MiB |
|
After Width: | Height: | Size: 230 KiB |
|
Before Width: | Height: | Size: 766 KiB |
|
After Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 1.9 MiB |
|
After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 204 KiB |
|
Before Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 194 KiB |
|
Before Width: | Height: | Size: 2.9 MiB |
|
After Width: | Height: | Size: 342 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 177 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 158 KiB |
|
Before Width: | Height: | Size: 2.2 MiB |
|
After Width: | Height: | Size: 223 KiB |
|
Before Width: | Height: | Size: 2.6 MiB |
|
After Width: | Height: | Size: 256 KiB |
|
Before Width: | Height: | Size: 2.3 MiB |
|
After Width: | Height: | Size: 236 KiB |
|
Before Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 2.7 MiB |
|
After Width: | Height: | Size: 184 KiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 5.4 KiB |
@@ -170,11 +170,13 @@ async function main() {
|
||||
const publicFaculty = path.join(root, "public", "images", "faculty");
|
||||
mkdirSync(publicFaculty, { recursive: true });
|
||||
|
||||
if (filesDir && existsSync(path.join(filesDir, "johndoe.png"))) {
|
||||
copyFileSync(
|
||||
path.join(filesDir, "johndoe.png"),
|
||||
path.join(publicFaculty, "placeholder.png"),
|
||||
);
|
||||
const destPlaceholder = path.join(publicFaculty, "placeholder.webp");
|
||||
if (
|
||||
filesDir &&
|
||||
existsSync(path.join(filesDir, "johndoe.png")) &&
|
||||
!existsSync(destPlaceholder)
|
||||
) {
|
||||
copyFileSync(path.join(filesDir, "johndoe.png"), destPlaceholder);
|
||||
}
|
||||
|
||||
const { Client } = pg;
|
||||
@@ -200,7 +202,7 @@ async function main() {
|
||||
byName.get(p.name.replace(/\s+/g, " ").trim().toLowerCase());
|
||||
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 isPlaceholder =
|
||||
!fileBase ||
|
||||
|
||||
@@ -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)`,
|
||||
);
|
||||
@@ -28,7 +28,7 @@ export default async function AlumniPage() {
|
||||
<PageHero
|
||||
title={t("alumniTitle")}
|
||||
intro={t("alumniIntro")}
|
||||
imageUrl="/brand/graduation-cap-neural.png"
|
||||
imageUrl="/brand/graduation-cap-neural.webp"
|
||||
/>
|
||||
<Section tone="subtle">
|
||||
<Container>
|
||||
|
||||
@@ -25,7 +25,7 @@ export default async function InsightsPage() {
|
||||
<PageHero
|
||||
title={t("insightsTitle")}
|
||||
intro={t("insightsIntro")}
|
||||
imageUrl="/brand/neural-open-book.png"
|
||||
imageUrl="/brand/neural-open-book.webp"
|
||||
/>
|
||||
<Section tone="subtle">
|
||||
<Container>
|
||||
|
||||
@@ -34,7 +34,7 @@ export default async function ProgramsPage() {
|
||||
<PageHero
|
||||
title={t("programsTitle")}
|
||||
intro={t("programsIntro")}
|
||||
imageUrl="/brand/neural-tree-knowledge.png"
|
||||
imageUrl="/brand/neural-tree-knowledge.webp"
|
||||
/>
|
||||
<Section tone="subtle">
|
||||
<Container className="space-y-16">
|
||||
|
||||
@@ -29,7 +29,7 @@ export default async function ValuesPage() {
|
||||
eyebrow={valuesContent.eyebrow}
|
||||
title={valuesContent.title}
|
||||
intro={valuesContent.intro}
|
||||
imageUrl="/brand/collective-intelligence.png"
|
||||
imageUrl="/brand/collective-intelligence.webp"
|
||||
/>
|
||||
|
||||
<Section tone="subtle">
|
||||
|
||||
@@ -54,7 +54,7 @@ export async function generateMetadata(): Promise<Metadata> {
|
||||
title: t("homeTitle"),
|
||||
description: t("homeDescription"),
|
||||
images: [
|
||||
{ url: "/brand/mst-faculty.png", alt: "دانشکده مدیریت، علم و فناوری دانشگاه صنعتی امیرکبیر" },
|
||||
{ url: "/brand/mst-faculty.webp", alt: "دانشکده مدیریت، علم و فناوری دانشگاه صنعتی امیرکبیر" },
|
||||
],
|
||||
},
|
||||
twitter: {
|
||||
|
||||
@@ -56,7 +56,7 @@ function LoginForm() {
|
||||
<CardHeader className="space-y-3 text-center">
|
||||
<div className="mx-auto relative size-14">
|
||||
<Image
|
||||
src="/brand/mst-faculty.png"
|
||||
src="/brand/mst-faculty.webp"
|
||||
alt="دانشگاه صنعتی امیرکبیر"
|
||||
fill
|
||||
sizes="56px"
|
||||
|
||||
@@ -3,9 +3,9 @@ import Link from "next/link";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
/** 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. */
|
||||
const HORIZONTAL_SRC = "/MstAutIcon_horizontal.png";
|
||||
const HORIZONTAL_SRC = "/MstAutIcon_horizontal.webp";
|
||||
|
||||
type BrandLogoProps = {
|
||||
href?: string;
|
||||
|
||||
@@ -24,7 +24,7 @@ export function HeroFeatured({
|
||||
<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>
|
||||
<Image
|
||||
src="/brand/amirkabir-arches.png"
|
||||
src="/brand/amirkabir-arches.webp"
|
||||
alt=""
|
||||
fill
|
||||
priority
|
||||
|
||||
@@ -34,7 +34,7 @@ export function PageHero({
|
||||
)}
|
||||
>
|
||||
<Image
|
||||
src={imageUrl ?? "/brand/neural-learning-wave.png"}
|
||||
src={imageUrl ?? "/brand/neural-learning-wave.webp"}
|
||||
alt=""
|
||||
fill
|
||||
priority
|
||||
|
||||
@@ -37,7 +37,7 @@ export function AdminShell({
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<span className="relative size-6 shrink-0 md:hidden">
|
||||
<Image
|
||||
src="/brand/mst-faculty.png"
|
||||
src="/brand/mst-faculty.webp"
|
||||
alt=""
|
||||
fill
|
||||
sizes="24px"
|
||||
|
||||
@@ -110,7 +110,7 @@ export function AdminSidebar({ userName }: { userName: string }) {
|
||||
>
|
||||
<span className="relative size-8 shrink-0">
|
||||
<Image
|
||||
src="/brand/mst-faculty.png"
|
||||
src="/brand/mst-faculty.webp"
|
||||
alt=""
|
||||
fill
|
||||
sizes="32px"
|
||||
|
||||
@@ -36,7 +36,7 @@ export function AboutTemplate({ topics }: { topics: IntersectionTopic[] }) {
|
||||
eyebrow={aboutContent.eyebrow}
|
||||
title={aboutContent.title}
|
||||
intro={aboutContent.intro}
|
||||
imageUrl="/brand/university-emblem-neural.png"
|
||||
imageUrl="/brand/university-emblem-neural.webp"
|
||||
/>
|
||||
|
||||
<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="relative order-1 aspect-[16/10] overflow-hidden rounded-2xl bg-primary lg:order-none">
|
||||
<Image
|
||||
src="/brand/ai-learning-frames.png"
|
||||
src="/brand/ai-learning-frames.webp"
|
||||
alt="یادگیری مبتنی بر هوش مصنوعی و چارچوب های دانشگاهی"
|
||||
fill
|
||||
className="object-cover object-center"
|
||||
|
||||
@@ -215,7 +215,7 @@ export function HomeApproach() {
|
||||
</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">
|
||||
<Image
|
||||
src="/brand/campus-collaboration-v1.png"
|
||||
src="/brand/campus-collaboration-v1.webp"
|
||||
alt="رویکرد آموزشی مرکز آموزش های آزاد"
|
||||
fill
|
||||
className="object-cover"
|
||||
|
||||
@@ -61,7 +61,7 @@ export function ProfessionalLandingTemplate({
|
||||
eyebrow={labels.offeredBy}
|
||||
title={labels.heroTitle}
|
||||
intro={labels.heroBody}
|
||||
imageUrl="/brand/executive-seminar-neural.png"
|
||||
imageUrl="/brand/executive-seminar-neural.webp"
|
||||
actions={
|
||||
<DotCta href="#programs" onDark>
|
||||
{labels.exploreCourses}
|
||||
@@ -105,7 +105,7 @@ export function ProfessionalLandingTemplate({
|
||||
>
|
||||
<div className="pointer-events-none absolute inset-0" aria-hidden>
|
||||
<Image
|
||||
src="/brand/ai-learning-frames.png"
|
||||
src="/brand/ai-learning-frames.webp"
|
||||
alt=""
|
||||
fill
|
||||
className="object-cover object-[60%_45%] opacity-25 mix-blend-screen"
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
type ParsedMstFaculty,
|
||||
} 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;
|
||||
|
||||
export type FacultySyncResult = {
|
||||
@@ -126,7 +126,7 @@ async function resolveImageUrl(
|
||||
|
||||
if (opts.localImageDir && isPlaceholderSrc(src)) {
|
||||
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))) {
|
||||
await copyFile(from, dest);
|
||||
}
|
||||
|
||||
@@ -27,11 +27,7 @@ export const siteAddress = {
|
||||
phone: "۰۲۱-۶۴۵۴۵۸۵۸",
|
||||
phoneTel: "+982164545858",
|
||||
email: "mst@aut.ac.ir",
|
||||
mapUrl:
|
||||
"https://maps.google.com/?q=" +
|
||||
encodeURIComponent(
|
||||
"تهران، خیابان انقلاب غرب، کوچه سعید، بنبست نائینی، ساختمان زکریای رازی",
|
||||
),
|
||||
mapUrl: "https://maps.app.goo.gl/RKKhZvN6cLYsmrKa8",
|
||||
};
|
||||
|
||||
/** Main nav labels for Persian users (seed/reference — runtime uses site-config + course-nav). */
|
||||
|
||||
@@ -30,7 +30,7 @@ export function pageMetadata(opts: {
|
||||
absoluteTitle?: boolean;
|
||||
}): Metadata {
|
||||
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 {
|
||||
title: opts.absoluteTitle ? { absolute: opts.title } : opts.title,
|
||||
description: opts.description,
|
||||
|
||||
@@ -93,11 +93,7 @@ export const siteAddress = {
|
||||
/** ASCII for tel: / schema */
|
||||
phoneTel: "+982164545858",
|
||||
email: "mst@aut.ac.ir",
|
||||
mapUrl:
|
||||
"https://maps.google.com/?q=" +
|
||||
encodeURIComponent(
|
||||
"تهران، خیابان انقلاب غرب، کوچه سعید، بنبست نائینی، ساختمان زکریای رازی",
|
||||
),
|
||||
mapUrl: "https://maps.app.goo.gl/RKKhZvN6cLYsmrKa8",
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||