fix(website): fix audit bugs, SVG inline headers, contact localization, and clean scripts
Deploy Frontend / deploy (push) Successful in 6m33s

This commit is contained in:
Parsa Aghayi committed 2026-11-02 06:53:45 +00:00
1 parent 98c43c4b30
commit 8d91da7677
10 files changed
+227 -35

No files matched your search

+4 -4
View File
@@ -10,19 +10,19 @@ import { Metadata } from "next";
import { SITE_URL, ogImageUrl } from "@/app/lib/site-config";
const description =
"Hi, I am Parsa Aghayi, a Frontend & Backend Developer. Here's my personal website to know more about me and contact me if you want! ;)";
"Parsa Aghayi - Senior Full-Stack Engineer & Web Architect. Personal portfolio, enterprise projects, technical architecture, and engineering blog.";
export const metadata: Metadata = {
title: "Parsa Aghayi's Personal Website",
title: "Senior Full-Stack Engineer & Web Architect",
description,
openGraph: {
title: "Parsa Aghayi's Personal Website",
title: "Parsa Aghayi | Senior Full-Stack Engineer & Web Architect",
description,
images: [`${SITE_URL}/images/profile.png`],
},
twitter: {
card: "summary_large_image",
title: "Parsa Aghayi's Personal Website",
title: "Parsa Aghayi | Senior Full-Stack Engineer & Web Architect",
description,
images: [ogImageUrl("Parsa Aghayi")],
},
@@ -12,6 +12,21 @@ interface ContactProps {
description: string;
button: string;
placeholder: string;
form?: {
nameLabel?: string;
namePlaceholder?: string;
emailLabel?: string;
emailPlaceholder?: string;
messageLabel?: string;
messagePlaceholder?: string;
errorSummaryTitle?: string;
errorNameRequired?: string;
errorEmailRequired?: string;
errorEmailInvalid?: string;
errorMessageRequired?: string;
successMessage?: string;
errorMessage?: string;
};
};
};
};
@@ -55,6 +70,7 @@ export default function Contact({ dict }: ContactProps) {
<ContactForm
buttonLabel={dict.website.homePage.contact.button}
emailPlaceholder={dict.website.homePage.contact.placeholder}
formDict={dict.website.homePage.contact.form}
/>
</motion.div>
</section>
@@ -22,7 +22,23 @@ type FieldErrors = Partial<Record<FieldName, string>>;
const EMPTY_VALUES: FormValues = { name: "", email: "", message: "" };
const ERROR_MESSAGES = {
export interface ContactFormDict {
nameLabel?: string;
namePlaceholder?: string;
emailLabel?: string;
emailPlaceholder?: string;
messageLabel?: string;
messagePlaceholder?: string;
errorSummaryTitle?: string;
errorNameRequired?: string;
errorEmailRequired?: string;
errorEmailInvalid?: string;
errorMessageRequired?: string;
successMessage?: string;
errorMessage?: string;
}
const DEFAULT_ERROR_MESSAGES = {
nameRequired: "لطفاً نام خود را وارد کنید.",
emailRequired: "لطفاً ایمیل خود را وارد کنید.",
emailInvalid: "لطفاً یک ایمیل معتبر وارد کنید. مثال: name@example.com",
@@ -35,19 +51,24 @@ type SubmitState =
| { status: "success" }
| { status: "error"; message: string };
function validate(values: FormValues): FieldErrors {
function validate(values: FormValues, formDict?: ContactFormDict): FieldErrors {
const errors: FieldErrors = {};
const name = values.name.trim();
const email = values.email.trim();
const message = values.message.trim();
if (!name) errors.name = ERROR_MESSAGES.nameRequired;
const nameRequired = formDict?.errorNameRequired || DEFAULT_ERROR_MESSAGES.nameRequired;
const emailRequired = formDict?.errorEmailRequired || DEFAULT_ERROR_MESSAGES.emailRequired;
const emailInvalid = formDict?.errorEmailInvalid || DEFAULT_ERROR_MESSAGES.emailInvalid;
const messageRequired = formDict?.errorMessageRequired || DEFAULT_ERROR_MESSAGES.messageRequired;
if (!name) errors.name = nameRequired;
if (!email) {
errors.email = ERROR_MESSAGES.emailRequired;
errors.email = emailRequired;
} else if (!EMAIL_SHAPE.test(email)) {
errors.email = ERROR_MESSAGES.emailInvalid;
errors.email = emailInvalid;
}
if (!message) errors.message = ERROR_MESSAGES.messageRequired;
if (!message) errors.message = messageRequired;
return errors;
}
@@ -55,11 +76,13 @@ function validate(values: FormValues): FieldErrors {
interface ContactFormProps {
buttonLabel: string;
emailPlaceholder: string;
formDict?: ContactFormDict;
}
export default function ContactForm({
buttonLabel,
emailPlaceholder,
formDict,
}: ContactFormProps) {
const [values, setValues] = useState<FormValues>(EMPTY_VALUES);
const [errors, setErrors] = useState<FieldErrors>({});
@@ -98,6 +121,9 @@ export default function ContactForm({
}
};
const isRtl = /[\u0600-\u06FF]/.test(buttonLabel || formDict?.nameLabel || "");
const dir = isRtl ? "rtl" : "ltr";
const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
@@ -107,7 +133,7 @@ export default function ContactForm({
message: values.message.trim(),
};
const nextErrors = validate(trimmed);
const nextErrors = validate(trimmed, formDict);
if (Object.keys(nextErrors).length > 0) {
// Ask for focus to move to the first field that needs fixing, so the announced
@@ -135,7 +161,7 @@ export default function ContactForm({
errors?: Record<string, string[]>;
} | null;
const first = payload?.errors ? Object.values(payload.errors)[0]?.[0] : undefined;
throw new Error(first ?? payload?.message ?? "ثبت پیام با خطا مواجه شد.");
throw new Error(first ?? payload?.message ?? (formDict?.errorMessage || "ثبت پیام با خطا مواجه شد."));
}
setValues(EMPTY_VALUES);
@@ -146,7 +172,7 @@ export default function ContactForm({
message:
error instanceof Error
? error.message
: "ثبت پیام با خطا مواجه شد. کمی بعد دوباره تلاش کنید.",
: (formDict?.errorMessage || "ثبت پیام با خطا مواجه شد. کمی بعد دوباره تلاش کنید."),
});
}
};
@@ -158,7 +184,7 @@ export default function ContactForm({
return (
<form
ref={formRef}
dir="rtl"
dir={dir}
noValidate
onSubmit={handleSubmit}
className="flex flex-col gap-5"
@@ -172,9 +198,9 @@ export default function ContactForm({
>
<p className="flex items-center gap-2 font-bold">
<AlertCircle className="h-5 w-5 shrink-0" aria-hidden="true" />
لطفاً خطاهای فرم را برطرف کنید.
{formDict?.errorSummaryTitle || "لطفاً خطاهای فرم را برطرف کنید."}
</p>
<ul className="list-disc space-y-1 pr-5 text-sm">
<ul className={`list-disc space-y-1 ${isRtl ? "pr-5" : "pl-5"} text-sm`}>
{errorEntries.map(([field, message]) => (
<li key={field}>{message}</li>
))}
@@ -185,7 +211,7 @@ export default function ContactForm({
<div className="grid gap-5 md:grid-cols-2">
<div className="flex flex-col gap-2">
<label htmlFor={nameId} className="font-medium text-foreground">
نام و نام خانوادگی <span aria-hidden="true">*</span>
{formDict?.nameLabel || "نام و نام خانوادگی"} <span aria-hidden="true">*</span>
</label>
<input
type="text"
@@ -194,7 +220,7 @@ export default function ContactForm({
value={values.name}
onChange={handleChange("name")}
autoComplete="name"
placeholder="مثلاً: پارسا آقایی"
placeholder={formDict?.namePlaceholder || "مثلاً: پارسا آقایی"}
aria-invalid={Boolean(errors.name)}
aria-describedby={errors.name ? `${nameId}-error` : undefined}
className={`${inputClassName} ${errors.name ? invalidInputClassName : "border-border"}`}
@@ -208,7 +234,7 @@ export default function ContactForm({
<div className="flex flex-col gap-2">
<label htmlFor={emailId} className="font-medium text-foreground">
ایمیل <span aria-hidden="true">*</span>
{formDict?.emailLabel || "ایمیل"} <span aria-hidden="true">*</span>
</label>
<input
type="email"
@@ -217,7 +243,7 @@ export default function ContactForm({
value={values.email}
onChange={handleChange("email")}
autoComplete="email"
placeholder={emailPlaceholder}
placeholder={emailPlaceholder || formDict?.emailPlaceholder || "name@example.com"}
aria-invalid={Boolean(errors.email)}
aria-describedby={errors.email ? `${emailId}-error` : undefined}
className={`${inputClassName} ${errors.email ? invalidInputClassName : "border-border"}`}
@@ -232,7 +258,7 @@ export default function ContactForm({
<div className="flex flex-col gap-2">
<label htmlFor={messageId} className="font-medium text-foreground">
پیام <span aria-hidden="true">*</span>
{formDict?.messageLabel || "پیام"} <span aria-hidden="true">*</span>
</label>
<textarea
id={messageId}
@@ -240,7 +266,7 @@ export default function ContactForm({
value={values.message}
onChange={handleChange("message")}
rows={5}
placeholder="درخواست، پیشنهاد همکاری یا هر سؤالی دارید بنویسید..."
placeholder={formDict?.messagePlaceholder || "درخواست، پیشنهاد همکاری یا هر سؤالی دارید بنویسید..."}
aria-invalid={Boolean(errors.message)}
aria-describedby={errors.message ? `${messageId}-error` : undefined}
className={`${inputClassName} resize-y ${
@@ -262,7 +288,7 @@ export default function ContactForm({
>
{submitState.status === "sending" ? (
<>
<span>در حال ارسال…</span>
<span>{isRtl ? "در حال ارسال…" : "Sending…"}</span>
<Loader2 className="h-4 w-4 animate-spin" aria-hidden="true" />
</>
) : (
@@ -281,7 +307,7 @@ export default function ContactForm({
className="mt-0.5 h-5 w-5 shrink-0 text-primary"
aria-hidden="true"
/>
<span>پیام شما با موفقیت ثبت شد. در اولین فرصت بررسی می‌شود.</span>
<span>{formDict?.successMessage || "پیام شما با موفقیت ثبت شد. در اولین فرصت بررسی می‌شود."}</span>
</p>
)}
+22 -7
View File
@@ -69,10 +69,25 @@
]
},
"contact": {
"slogan": "Lets Design Together",
"slogan": "Let's Design Together",
"description": "The Contact Me section offers a simple way to reach out for inquiries, project proposals, or collaboration opportunities. Fill out the contact form or use the provided information, and I'll respond promptly to discuss your ideas and how I can help.",
"button": "contact me",
"placeholder": "Enter your Email address here..."
"button": "Contact Me",
"placeholder": "Enter your Email address here...",
"form": {
"nameLabel": "Full Name",
"namePlaceholder": "e.g. John Doe",
"emailLabel": "Email Address",
"emailPlaceholder": "name@example.com",
"messageLabel": "Your Message",
"messagePlaceholder": "Describe your project or inquiry...",
"errorSummaryTitle": "Please correct the errors in the form.",
"errorNameRequired": "Please enter your name.",
"errorEmailRequired": "Please enter your email address.",
"errorEmailInvalid": "Please enter a valid email address.",
"errorMessageRequired": "Please write your message.",
"successMessage": "Your message has been sent successfully! I'll get back to you soon.",
"errorMessage": "Failed to send message. Please try again later."
}
}
},
"header": {
@@ -95,8 +110,8 @@
"Testimonials": "testimonials",
"Contact": "contact",
"Blog": "blog",
"Year": "© 2024",
"CopyRight": "All Rights Reserved , Inc."
"Year": "© 2026",
"CopyRight": "All Rights Reserved, Inc."
}
},
"blog": {
@@ -159,8 +174,8 @@
},
"footer": {
"Name": "parsa aghayi",
"Year": "© 2024",
"CopyRight": "All Rights Reserved , Inc."
"Year": "© 2026",
"CopyRight": "All Rights Reserved, Inc."
},
"pagination": {
"first": "first",
+18 -3
View File
@@ -72,7 +72,22 @@
"slogan": "بیایید با هم طراحی کنیم",
"description": "بخش تماس با من راهی ساده برای ارتباط جهت استعلامات، پیشنهادهای پروژه یا فرصت‌های همکاری است. فرم تماس را پر کنید یا از اطلاعات ارائه شده استفاده کنید و من سریعاً برای بحث درباره ایده‌های شما و نحوه کمک من پاسخ خواهم داد.",
"button": "تماس با من",
"placeholder": "آدرس ایمیل خود را اینجا وارد کنید..."
"placeholder": "آدرس ایمیل خود را اینجا وارد کنید...",
"form": {
"nameLabel": "نام و نام خانوادگی",
"namePlaceholder": "مثلاً: پارسا آقایی",
"emailLabel": "ایمیل",
"emailPlaceholder": "name@example.com",
"messageLabel": "پیام",
"messagePlaceholder": "پیام خود را اینجا بنویسید...",
"errorSummaryTitle": "لطفاً خطاهای فرم را برطرف کنید.",
"errorNameRequired": "لطفاً نام خود را وارد کنید.",
"errorEmailRequired": "لطفاً ایمیل خود را وارد کنید.",
"errorEmailInvalid": "لطفاً یک ایمیل معتبر وارد کنید. مثال: name@example.com",
"errorMessageRequired": "لطفاً متن پیام خود را بنویسید.",
"successMessage": "پیام شما با موفقیت ارسال شد! به زودی با شما تماس خواهم گرفت.",
"errorMessage": "ثبت پیام با خطا مواجه شد. کمی بعد دوباره تلاش کنید."
}
}
},
"header": {
@@ -95,7 +110,7 @@
"Testimonials": "نظرات",
"Contact": "تماس",
"Blog": "وبلاگ",
"Year": "© ۲۰۲۴",
"Year": "© ۲۰۲۶",
"CopyRight": "تمامی حقوق محفوظ است"
}
},
@@ -159,7 +174,7 @@
},
"footer": {
"Name": "پارسا آقایی",
"Year": "© ۲۰۲۴",
"Year": "© ۲۰۲۶",
"CopyRight": "تمامی حقوق محفوظ است"
},
"pagination": {