diff --git a/src/app/(routes)/blog/categories/[categorySlug]/page.tsx b/src/app/(routes)/blog/categories/[categorySlug]/page.tsx index 8d2c851..639a1cc 100644 --- a/src/app/(routes)/blog/categories/[categorySlug]/page.tsx +++ b/src/app/(routes)/blog/categories/[categorySlug]/page.tsx @@ -19,7 +19,7 @@ async function fetchCategoryData( const res = await fetch( `${process.env.NEXT_PUBLIC_BLOG_API_URL}/categories/${categorySlug}/posts?per_page=${searchParams.get("per_page") || process.env.NEXT_PUBLIC_POSTS_PER_CATEGORY_PAGE}${searchParams.get("page") ? `&page=${searchParams.get("page")}` : ""}&lang=${locale}`, { - cache: process.env.NEXT_PUBLIC_BLOG_CACHE ? "force-cache" : "no-store", + cache: "no-store", }, ); diff --git a/src/app/(routes)/blog/categories/page.tsx b/src/app/(routes)/blog/categories/page.tsx index 8413d89..19ffc60 100644 --- a/src/app/(routes)/blog/categories/page.tsx +++ b/src/app/(routes)/blog/categories/page.tsx @@ -30,7 +30,7 @@ export default async function Categories(props: categoryPropsType) { const CategoriesData: CategoriesListType = await fetch( `${process.env.NEXT_PUBLIC_BLOG_API_URL}/categories?per_page=${searchParams.per_page ? searchParams.per_page : process.env.NEXT_PUBLIC_CATEGORIES_PER_CATEGORY_PAGE}${searchParams.page ? `&page=${searchParams.page}` : ""}&lang=${locale}`, { - cache: process.env.NEXT_PUBLIC_BLOG_CACHE ? "force-cache" : "no-store", + cache: "no-store", }, ).then((res) => res.json()); diff --git a/src/app/(routes)/blog/components/header/header.tsx b/src/app/(routes)/blog/components/header/header.tsx index 1373a1b..17f05e9 100644 --- a/src/app/(routes)/blog/components/header/header.tsx +++ b/src/app/(routes)/blog/components/header/header.tsx @@ -1,16 +1,21 @@ import Image from "next/image"; import React from "react"; -import Button from "../button/button"; import { NavLinks } from "./navLinks"; import Link from "next/link"; import BurgerButton from "../burger-button/burgerButton"; -import { cookies } from "next/headers"; import SelectLanguage from "../selectLanguage/selectLanguage"; +import SubscribeModal from "../subscribe/subscribeModal"; +import { cookies } from "next/headers"; import { getDictionary } from "@/app/lib/functions/dictionaries"; import { getDefaultLocale } from "@/app/lib/functions/utils"; export default async function Header() { const dict = await getDictionary(await getDefaultLocale()); + const subscribeLabels = { + buttonTitle: dict.blog.header.button, + trigger: dict.blog.header.button, + ...dict.blog.subscribeModal, + }; return (
@@ -41,11 +46,7 @@ export default async function Header() { alt="search icon" className="hidden hover:cursor-pointer sm:block" /> -
diff --git a/src/app/(routes)/blog/components/header/navLinks.tsx b/src/app/(routes)/blog/components/header/navLinks.tsx index 7819e47..867690d 100644 --- a/src/app/(routes)/blog/components/header/navLinks.tsx +++ b/src/app/(routes)/blog/components/header/navLinks.tsx @@ -32,6 +32,12 @@ export function NavLinks({ className, dict }: NavLinksPropsType) { > {dict.blog.header.Popular} + + {dict.blog.header.AllPosts} + @@ -109,7 +111,7 @@ export default async function New({ data }: NewProps) { className="flex w-full flex-col rounded-md p-2 transition-all hover:scale-105 hover:shadow-md" >

- {post.created_at} + {formatDate(post.created_at, locale)}

{dict.blog.homePage.newsletterText}

- - {dict.blog.homePage.subscribe} - + ); } \ No newline at end of file diff --git a/src/app/(routes)/blog/components/mobile-menu/mobileMenu.tsx b/src/app/(routes)/blog/components/mobile-menu/mobileMenu.tsx index 769ec7f..8925f65 100644 --- a/src/app/(routes)/blog/components/mobile-menu/mobileMenu.tsx +++ b/src/app/(routes)/blog/components/mobile-menu/mobileMenu.tsx @@ -71,6 +71,15 @@ export default function MobileMenu({ clicked, setClicked }: propsType) { > Popular + { + setClicked(false); + }} + > + All posts + = ({ meta, baseUrl, dict }) => { return `${baseUrl}?${params.toString()}`; // استفاده از baseUrl }; + const pageLinkClassName = (isCurrent: boolean) => + `flex h-9 min-w-[2.25rem] items-center justify-center rounded-full border px-2 text-[14px] font-[600] ${ + isCurrent + ? "border-blog-red bg-blog-red text-white" + : "border-transparent bg-[#EAEAEA] text-blog-text-default hover:bg-[#d6d6d6]" + }`; + + const arrowLinkClassName = + "flex h-9 min-w-[2.25rem] items-center justify-center rounded-full border border-transparent bg-[#EAEAEA] text-[20px] font-[600] leading-none text-blog-text-default transition-colors hover:bg-[#d6d6d6]"; + const renderPageNumbers = (): (React.JSX.Element | string)[] => { const delta = 1; // تعداد صفحات اطراف صفحه فعلی که نمایش داده شوند const range: number[] = []; @@ -64,7 +74,10 @@ const Pagination: React.FC = ({ meta, baseUrl, dict }) => { return rangeWithDots.map((page, index) => { if (page === "...") { return ( - + ... ); @@ -73,11 +86,7 @@ const Pagination: React.FC = ({ meta, baseUrl, dict }) => { {page} @@ -88,58 +97,54 @@ const Pagination: React.FC = ({ meta, baseUrl, dict }) => { }; return ( -
- {/* Page Numbers */} -
- {renderPageNumbers()} -
- -
- {/* First Page */} +
+ ); }; diff --git a/src/app/(routes)/blog/components/subscribe/subscribeModal.tsx b/src/app/(routes)/blog/components/subscribe/subscribeModal.tsx new file mode 100644 index 0000000..ca5e418 --- /dev/null +++ b/src/app/(routes)/blog/components/subscribe/subscribeModal.tsx @@ -0,0 +1,220 @@ +"use client"; + +import { FormEvent, useEffect, useState } from "react"; + +const BACKEND = + process.env.NEXT_PUBLIC_BACK_URL || "https://backend.parsaaghayi.ir"; + +const EMAIL_SHAPE = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/; + +type SubscribeLabels = { + buttonTitle: string; + trigger: string; + title: string; + text: string; + email: string; + mobile: string; + submit: string; + note: string; + success: string; + already: string; + error: string; + eitherRequired: string; + close: string; +}; + +type SubscribeModalProps = { + labels: SubscribeLabels; + variant: "header" | "cta"; +}; + +type Status = + | { kind: "idle" } + | { kind: "sending" } + | { kind: "done"; message: string }; + +export default function SubscribeModal({ + labels, + variant, +}: SubscribeModalProps) { + const [open, setOpen] = useState(false); + const [email, setEmail] = useState(""); + const [mobile, setMobile] = useState(""); + const [invalid, setInvalid] = useState(""); + const [status, setStatus] = useState({ kind: "idle" }); + + useEffect(() => { + if (!open) return; + + const onKey = (event: KeyboardEvent) => { + if (event.key === "Escape") { + setOpen(false); + } + }; + + document.addEventListener("keydown", onKey); + return () => document.removeEventListener("keydown", onKey); + }, [open]); + + const triggerClassName = + variant === "header" + ? "flex items-center justify-center rounded-[10px] bg-blog-purple px-[12px] py-[8px] text-[16px] font-[600] text-white shadow-md capitalize transition-all hover:scale-105 sm:px-[20px] sm:py-[12px]" + : "rounded-full bg-white px-8 py-3 text-[16px] font-[700] capitalize text-blog-purple transition-transform hover:scale-105"; + + const submit = async (event: FormEvent) => { + event.preventDefault(); + + const trimmedEmail = email.trim(); + const trimmedMobile = mobile.trim(); + + if (!trimmedEmail && !trimmedMobile) { + setInvalid(labels.eitherRequired); + return; + } + + if (trimmedEmail && !EMAIL_SHAPE.test(trimmedEmail)) { + setInvalid(labels.error); + return; + } + + setInvalid(""); + setStatus({ kind: "sending" }); + + try { + const response = await fetch(`${BACKEND}/api/newsletter/subscribe`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + email: trimmedEmail || undefined, + mobile: trimmedMobile || undefined, + }), + }); + + const payload = (await response.json().catch(() => null)) as { + message?: string; + } | null; + + if (response.status === 200) { + const already = payload?.message || labels.already; + setStatus({ kind: "done", message: already }); + return; + } + + if (response.ok) { + setEmail(""); + setMobile(""); + setStatus({ kind: "done", message: payload?.message || labels.success }); + return; + } + + setStatus({ kind: "done", message: labels.error }); + } catch { + setStatus({ kind: "done", message: labels.error }); + } + }; + + return ( + <> + + + {open ? ( +
+
setOpen(false)} + /> +
+
+
+

+ {labels.title} +

+

+ {labels.text} +

+
+ +
+ + {status.kind === "done" ? ( +

+ {status.message} +

+ ) : ( +
+ + + + + {invalid ? ( +

+ {invalid} +

+ ) : null} + +

+ {labels.note} +

+ + +
+ )} +
+
+ ) : null} + + ); +} \ No newline at end of file diff --git a/src/app/(routes)/blog/filtered-posts/[filter]/page.tsx b/src/app/(routes)/blog/filtered-posts/[filter]/page.tsx index 3c31245..a89191e 100644 --- a/src/app/(routes)/blog/filtered-posts/[filter]/page.tsx +++ b/src/app/(routes)/blog/filtered-posts/[filter]/page.tsx @@ -91,7 +91,7 @@ export default async function FilteredPosts(props: FilteredPostsPagepropsType) { FilteredPostsData = await fetch( `${process.env.NEXT_PUBLIC_BLOG_API_URL}${filteredPostApiUrl}&per_page=${searchParams.per_page ? searchParams.per_page : process.env.NEXT_PUBLIC_POSTS_PER_FILTERED_POSTS_PAGE}${searchParams.page ? `&page=${searchParams.page}` : ""}&lang=${locale}`, { - cache: process.env.NEXT_PUBLIC_BLOG_CACHE ? "force-cache" : "no-store", + cache: "no-store", }, ).then((res) => res.json()); } else { diff --git a/src/app/(routes)/blog/page.tsx b/src/app/(routes)/blog/page.tsx index e14f6d1..8be6183 100644 --- a/src/app/(routes)/blog/page.tsx +++ b/src/app/(routes)/blog/page.tsx @@ -15,7 +15,7 @@ export default async function Blog() { } = await fetch( `${process.env.NEXT_PUBLIC_BLOG_API_URL}/homepage?lang=${locale}`, { - cache: process.env.NEXT_PUBLIC_BLOG_CACHE ? "force-cache" : "no-store", + cache: "no-store", }, ).then((res) => res.json()); return ( diff --git a/src/app/(routes)/blog/posts/[postSlug]/comments.tsx b/src/app/(routes)/blog/posts/[postSlug]/comments.tsx index b8da16b..eee00e9 100644 --- a/src/app/(routes)/blog/posts/[postSlug]/comments.tsx +++ b/src/app/(routes)/blog/posts/[postSlug]/comments.tsx @@ -1,6 +1,7 @@ "use client"; import { useEffect, useState } from "react"; +import { formatDate } from "@/app/lib/functions/formatDate"; type CommentItem = { id: number; @@ -23,12 +24,13 @@ type CommentLabels = { type CommentSectionProps = { slug: string; + locale: string; labels: CommentLabels; }; const API_URL = process.env.NEXT_PUBLIC_BLOG_API_URL; -export default function CommentSection({ slug, labels }: CommentSectionProps) { +export default function CommentSection({ slug, locale, labels }: CommentSectionProps) { const [comments, setComments] = useState([]); const [name, setName] = useState(""); const [email, setEmail] = useState(""); @@ -98,7 +100,7 @@ export default function CommentSection({ slug, labels }: CommentSectionProps) { {comment.name}

- {formatDate(comment.created_at)} + {formatDate(comment.created_at, locale)}

@@ -176,14 +178,4 @@ export default function CommentSection({ slug, labels }: CommentSectionProps) { )} ); -} - -function formatDate(value: string): string { - const parsed = new Date(value); - - if (Number.isNaN(parsed.getTime())) { - return value; - } - - return new Intl.DateTimeFormat(undefined, { dateStyle: "medium" }).format(parsed); } \ No newline at end of file diff --git a/src/app/(routes)/blog/posts/[postSlug]/page.tsx b/src/app/(routes)/blog/posts/[postSlug]/page.tsx index 781a994..7c7956e 100644 --- a/src/app/(routes)/blog/posts/[postSlug]/page.tsx +++ b/src/app/(routes)/blog/posts/[postSlug]/page.tsx @@ -14,6 +14,7 @@ import Link from "next/link"; import { redirect } from "next/navigation"; import { getHeadings, renderBody } from "./body"; import { estimateReadingTime } from "./readingTime"; +import { formatDate } from "@/app/lib/functions/formatDate"; import ShareButtons from "../../components/share/shareButtons"; import CommentSection from "./comments"; import PostStats from "./postStats"; @@ -25,11 +26,11 @@ async function fetchPostData( postSlug: string, locale: string, ): Promise { + // Always live (never force-cache): the view and like counters must reflect the + // real API state on every render, not a snapshot cached at build or boot time. const res = await fetch( `${process.env.NEXT_PUBLIC_BLOG_API_URL}/posts/${postSlug}?lang=${locale}`, - { - cache: process.env.NEXT_PUBLIC_BLOG_CACHE ? "force-cache" : "no-store", - } + { cache: "no-store" }, ); if (res.status === 404) { @@ -56,22 +57,6 @@ async function resolvePostSlug(raw: string): Promise { return locale; } -function formatPostDate(value: unknown): string { - if (typeof value !== "string" || value.trim() === "") { - return ""; - } - - const parsed = new Date(value.trim()); - - if (Number.isNaN(parsed.getTime())) { - return value.trim(); - } - - return new Intl.DateTimeFormat("fa-IR", { dateStyle: "medium" }).format( - parsed, - ); -} - export async function generateMetadata(props: PostSlugPagepropsType): Promise { const params = await props.params; const locale = await resolvePostSlug(params.postSlug); @@ -132,7 +117,7 @@ export default async function SinglePost(props: PostSlugPagepropsType) { const authorName = post.author?.name ?? ""; const categoryName = post.category?.name ?? ""; const categorySlug = post.category?.slug ?? ""; - const publishedDate = formatPostDate(post.published_at); + const publishedDate = formatDate(post.published_at, locale); const postTags = Array.isArray(post.tags) ? post.tags : []; const relatedPosts = Array.isArray(postData.related_posts) ? postData.related_posts @@ -500,6 +485,7 @@ export default async function SinglePost(props: PostSlugPagepropsType) { { - if (sessionStorage.getItem(`blogViewed:${slug}`) === "1") { - return; - } - let cancelled = false; fetch(`${API_URL}/posts/${slug}/view`, { method: "POST" }) .then((res) => (res.ok ? res.json() : null)) .then((data) => { - if (!cancelled && data && typeof data.views === "number") { + if (cancelled || !data) return; + + if (typeof data.views === "number") { setViews(data.views); - try { - sessionStorage.setItem(`blogViewed:${slug}`, "1"); - } catch { - /* storage unavailable */ - } + } + if (typeof data.likes === "number") { + setLikes(data.likes); } }) .catch(() => undefined); diff --git a/src/app/(routes)/blog/posts/page.tsx b/src/app/(routes)/blog/posts/page.tsx index 7fac3b0..cf6f8b5 100644 --- a/src/app/(routes)/blog/posts/page.tsx +++ b/src/app/(routes)/blog/posts/page.tsx @@ -1,5 +1,135 @@ +import { + FilteredPostsDataType, + FilteredPostsPagepropsType, + PostType, +} from "@/app/types/types"; +import Image from "next/image"; +import Link from "next/link"; +import NoDataFounded from "../components/no-data-founded/noDataFounded"; +import Pagination from "../components/pagination/pagination"; +import { Metadata } from "next"; +import { getDictionary } from "@/app/lib/functions/dictionaries"; +import { getDefaultLocale } from "@/app/lib/functions/utils"; +import { ogImageUrl } from "@/app/lib/site-config"; +const ogImage = (text: string) => ogImageUrl(text); -export default function Posts() { - return

blog posts list page
; +export async function generateMetadata(): Promise { + const dict = await getDictionary(await getDefaultLocale()); + + return { + title: dict.blog.postsPage.title, + description: dict.blog.postsPage.description, + openGraph: { + title: dict.blog.postsPage.title, + description: dict.blog.postsPage.description, + images: [ogImage(dict.blog.postsPage.title)], + }, + }; } + +export default async function Posts(props: FilteredPostsPagepropsType) { + const searchParams = await props.searchParams; + const dict = await getDictionary(await getDefaultLocale()); + const locale = await getDefaultLocale(); + + const apiUrl = `${process.env.NEXT_PUBLIC_BLOG_API_URL}/posts?sort_field=published_at&sort_direction=desc&per_page=${searchParams.per_page ? searchParams.per_page : process.env.NEXT_PUBLIC_POSTS_PER_FILTERED_POSTS_PAGE}${searchParams.page ? `&page=${searchParams.page}` : ""}&lang=${locale}`; + + const postsData: FilteredPostsDataType = await fetch(apiUrl, { + cache: "no-store", + }).then((res) => res.json()); + + return ( +
+
+

+ {dict.blog.postsPage.title} +

+

+ {dict.blog.postsPage.description} +

+
+
+
    +
  • + + {dict.blog.header.Home} + + + - + +
  • +
  • +

    + {dict.blog.postsPage.title} + + {postsData.meta.total} + +

    +
  • +
+ +
+ {postsData.data.length > 0 ? ( + postsData.data.map((post: PostType) => ( +
+ {`${post.title} +
+
+

+ {dict.blog.homePage.by} +

+ + {post.author.name} + +
+
+

+ {dict.blog.homePage.in} +

+ + {post.category.name} + +
+
+ + {post.title} + +

+ {post.excerpt} +

+
+ )) + ) : ( + + )} +
+ {postsData.data.length > 0 && postsData.meta.last_page > 1 && ( + + )} +
+
+ ); +} \ No newline at end of file diff --git a/src/app/(routes)/blog/tags/[slug]/page.tsx b/src/app/(routes)/blog/tags/[slug]/page.tsx index c36171d..f562003 100644 --- a/src/app/(routes)/blog/tags/[slug]/page.tsx +++ b/src/app/(routes)/blog/tags/[slug]/page.tsx @@ -22,7 +22,7 @@ async function fetchTagData( const res = await fetch( `${process.env.NEXT_PUBLIC_BLOG_API_URL}/tags/by-slug/${slug}/posts?per_page=${searchParams.get("per_page") || process.env.NEXT_PUBLIC_POSTS_PER_CATEGORY_PAGE}${searchParams.get("page") ? `&page=${searchParams.get("page")}` : ""}&lang=${locale}`, { - cache: process.env.NEXT_PUBLIC_BLOG_CACHE ? "force-cache" : "no-store", + cache: "no-store", }, ); diff --git a/src/app/(routes)/og-image/Vazirmatn-Bold.ttf b/src/app/(routes)/og-image/Vazirmatn-Bold.ttf new file mode 100644 index 0000000..efa9b09 Binary files /dev/null and b/src/app/(routes)/og-image/Vazirmatn-Bold.ttf differ diff --git a/src/app/(routes)/og-image/Vazirmatn-Regular.ttf b/src/app/(routes)/og-image/Vazirmatn-Regular.ttf new file mode 100644 index 0000000..64e4a81 Binary files /dev/null and b/src/app/(routes)/og-image/Vazirmatn-Regular.ttf differ diff --git a/src/app/(routes)/og-image/route.tsx b/src/app/(routes)/og-image/route.tsx index 9d28433..1228f30 100644 --- a/src/app/(routes)/og-image/route.tsx +++ b/src/app/(routes)/og-image/route.tsx @@ -1,16 +1,37 @@ import { ImageResponse } from "next/og"; +import { hasArabicScript, shapeArabic } from "./shape"; export const runtime = "edge"; +const REGULAR_FONT = fetch( + new URL("./Vazirmatn-Regular.ttf", import.meta.url), +).then((res) => res.arrayBuffer()); + +const BOLD_FONT = fetch( + new URL("./Vazirmatn-Bold.ttf", import.meta.url), +).then((res) => res.arrayBuffer()); + export async function GET(request: Request) { const { searchParams } = new URL(request.url); - const text = searchParams.get("text") || "Hello world!"; + const raw = searchParams.get("text") || "Hello world!"; + + // The renderer lays characters out without contextual Arabic joining, so + // Persian/Arabic titles are pre-shaped into connected presentation forms; + // raw letters would otherwise be drawn one by one (د-س-ت-ا-چ-ی). + const isRtl = hasArabicScript(raw); + const text = isRtl ? shapeArabic(raw) : raw; + + const [regular, bold] = await Promise.all([REGULAR_FONT, BOLD_FONT]); return new ImageResponse( (
{text} @@ -28,6 +49,10 @@ export async function GET(request: Request) { { width: 1200, height: 1200, + fonts: [ + { name: "Vazirmatn", data: regular, weight: 400, style: "normal" }, + { name: "Vazirmatn", data: bold, weight: 700, style: "normal" }, + ], }, ); -} +} \ No newline at end of file diff --git a/src/app/(routes)/og-image/shape.ts b/src/app/(routes)/og-image/shape.ts new file mode 100644 index 0000000..88b0e89 --- /dev/null +++ b/src/app/(routes)/og-image/shape.ts @@ -0,0 +1,114 @@ +/** + * Minimal Arabic/Persian text shaper for the OG-image route. + * + * The core image renderer lays text out character by character and cannot run a + * real shaping engine (HarfBuzz), so Persian letters come back disconnected. By + * pre-joining the letters ourselves into Unicode presentation forms (the forms a + * shaping engine would have produced), the renderer only has to place glyphs. + * + * Only the conservative Persian glyph subset is covered, which is what blog + * titles actually use; any character without a presentation form is left as-is. + */ + +/** A joinable letter and its four presentation forms: isolated, final, initial, medial. */ +const DUAL_FORMS: Record = { + 0x0628: [0x0628, 0xfe90, 0xfe91, 0xfe92], // ب + 0x062a: [0x062a, 0xfe96, 0xfe97, 0xfe98], // ت + 0x062b: [0x062b, 0xfe9a, 0xfe9b, 0xfe9c], // ث + 0x062c: [0x062c, 0xfe9e, 0xfe9f, 0xfea0], // ج + 0x062d: [0x062d, 0xfea2, 0xfea3, 0xfea4], // ح + 0x062e: [0x062e, 0xfea6, 0xfea7, 0xfea8], // خ + 0x0633: [0x0633, 0xfeb2, 0xfeb3, 0xfeb4], // س + 0x0634: [0x0634, 0xfeb6, 0xfeb7, 0xfeb8], // ش + 0x0635: [0x0635, 0xfeba, 0xfebb, 0xfebc], // ص + 0x0636: [0x0636, 0xfebe, 0xfebf, 0xfec0], // ض + 0x0637: [0x0637, 0xfec2, 0xfec3, 0xfec4], // ط + 0x0638: [0x0638, 0xfec6, 0xfec7, 0xfec8], // ظ + 0x0639: [0x0639, 0xfeca, 0xfecb, 0xfecc], // ع + 0x063a: [0x063a, 0xfece, 0xfecf, 0xfed0], // غ + 0x0641: [0x0641, 0xfed2, 0xfed3, 0xfed4], // ف + 0x0642: [0x0642, 0xfed6, 0xfed7, 0xfed8], // ق + 0x0643: [0x0643, 0xfeda, 0xfedb, 0xfedc], // ك (Arabic kaf) + 0x0644: [0x0644, 0xfede, 0xfedf, 0xfee0], // ل + 0x0645: [0x0645, 0xfee2, 0xfee3, 0xfee4], // م + 0x0646: [0x0646, 0xfee6, 0xfee7, 0xfee8], // ن + 0x0647: [0x0647, 0xfeea, 0xfeeb, 0xfeec], // ه + 0x064a: [0x064a, 0xfef2, 0xfef3, 0xfef4], // ي (Arabic yeh) + 0x06a9: [0x06a9, 0xfb91, 0xfb92, 0xfb93], // ک (Persian kaf) + 0x06af: [0x06af, 0xfb95, 0xfb96, 0xfb97], // گ + 0x06cc: [0x06cc, 0xfbfd, 0xfbfe, 0xfbff], // ی (Persian yeh) + 0x067e: [0x067e, 0xfb57, 0xfb58, 0xfb59], // پ + 0x0686: [0x0686, 0xfb7b, 0xfb7c, 0xfb7d], // چ + 0x0626: [0x0626, 0xfe8a, 0xfe8b, 0xfe8c], // ئ + 0x0640: [0x0640, 0x0640, 0x0640, 0x0640], // ـ (tatweel/kashida, joins everywhere) +}; + +/** + * Letters that attach to a preceding letter but never grow an initial/medial + * form of their own (they only ever take isolated or final shapes). + */ +const RIGHT_ONLY = new Set([ + 0x0622, // آ + 0x0623, // أ + 0x0624, // ؤ + 0x0625, // إ + 0x0627, // ا + 0x0629, // ة + 0x062f, // د + 0x0630, // ذ + 0x0631, // ر + 0x0632, // ز + 0x0648, // و + 0x0698, // ژ + 0x0621, // ء +]); + +const HAS_ARABIC_SCRIPT = /[\u0600-\u06ff\u0750-\u077f\u08a0-\u08ff]/; + +export function hasArabicScript(text: string): boolean { + return HAS_ARABIC_SCRIPT.test(text); +} + +function isJoinable(codePoint: number): boolean { + return codePoint in DUAL_FORMS || RIGHT_ONLY.has(codePoint); +} + +/** + * Joins the letters of a Persian/Arabic string into presentation-form codepoints + * so a non-shaping renderer shows them connected, not letter by letter. + */ +export function shapeArabic(text: string): string { + const codePoints = Array.from(text.trim()); + const out: string[] = []; + + for (let i = 0; i < codePoints.length; i += 1) { + const char = codePoints[i]; + const codePoint = char.codePointAt(0) as number; + + const forms = DUAL_FORMS[codePoint]; + + if (!forms) { + out.push(char); + continue; + } + + const previous = i > 0 ? (codePoints[i - 1].codePointAt(0) as number) : null; + const next = + i + 1 < codePoints.length ? (codePoints[i + 1].codePointAt(0) as number) : null; + + const connectsToPrevious = previous !== null && isJoinable(previous); + const connectsToNext = next !== null && isJoinable(next); + + const formIndex = connectsToPrevious + ? connectsToNext + ? 3 // medial + : 1 // final + : connectsToNext + ? 2 // initial + : 0; // isolated + + out.push(String.fromCodePoint(forms[formIndex] as number)); + } + + return out.join(""); +} \ No newline at end of file diff --git a/src/app/lib/dictionaries/en.json b/src/app/lib/dictionaries/en.json index b06bab3..143d583 100644 --- a/src/app/lib/dictionaries/en.json +++ b/src/app/lib/dictionaries/en.json @@ -1,169 +1,187 @@ { - "website": { - "homePage": { - "top": { - "greeting": "Hi, I am", - "name": "Parsa Aghayi", - "profession": "Senior Frontend Engineer & Web Architect", - "roll": "Turning complex engineering challenges into clean, maintainable code.", - "descriptionAboutMe": "Crafting high-performance web applications, scalable React/Next.js architectures, and seamless backend integrations. Turning complex engineering challenges into clean, maintainable code.", - "cta": "Let's Work Together" - }, - "nav": { - "home": "home", - "aboutMe": "about Me", - "services": "services", - "projects": "projects", - "testimonials": "testimonials", - "contact": "contact", - "blog": "blog" - }, - "services": { - "title": "services", - "description": "In today's digital landscape, having a robust online presence is essential for businesses and individuals alike. Our services cater to a wide range of web development needs, ensuring that your project is functional, visually appealing, and user-friendly." - }, - "projects": { - "title": "my projects", - "description": "Explore a selection of my web development projects that showcase my ability to deliver high-quality solutions and create engaging digital experiences. See how I can help bring your vision to life!" - }, - "testimonials": { - "title": "testimonials", - "description": "The Testimonials section features feedback from clients and collaborators, highlighting the quality of my services and commitment to client satisfaction. These authentic reviews reflect my professionalism and the positive impact of my work, giving potential clients confidence in choosing me for their web development needs.", - "data": [ - { - "name": "Sarah Johnson", - "position": "Founder & CEO of Innovate Solutions", - "image": "/images/user-1.svg", - "quote": "Parsa rebuilt our corporate website from the ground up. Load times dropped by 60% and the new React/Next.js architecture made content updates effortless for our team. Conversion rates have been climbing steadily ever since launch." - }, - { - "name": "Michael Lee", - "position": "Chief Executive Officer at Tech Innovators", - "image": "/images/user-1.svg", - "quote": "What impressed me most was Parsa's clarity. He translated complex technical requirements into a clear roadmap, delivered on schedule, and documented everything so our own team could maintain the project independently." - }, - { - "name": "Emma Davis", - "position": "CEO & Lead Strategist at Visionary Ventures", - "image": "/images/user-1.svg", - "quote": "The attention to detail was outstanding. From responsive design to accessibility and SEO, every aspect of our platform felt thoughtful. Parsa genuinely invested time in understanding our business before writing a single line of code." - }, - { - "name": "John Doe", - "position": "COO at Startup Labs", - "image": "/images/user-1.svg", - "quote": "Our previous agency left us with an unstable product. Parsa took over, stabilized the codebase, and shipped the MVP we needed within a few weeks. Professional, communicative, and pragmatic from start to finish." - }, - { - "name": "Jane Smith", - "position": "Founder at Health Innovations", - "image": "/images/user-1.svg", - "quote": "Our web app handles sensitive user data, so security and reliability were non-negotiable. Parsa delivered a clean, secure architecture and was always quick to respond whenever we had questions." - }, - { - "name": "Alex Chen", - "position": "CTO at CloudBase Technologies", - "image": "/images/user-1.svg", - "quote": "Parsa is that rare engineer who cares about the whole product, not just the code. Backend integrations, deployment pipelines, performance — he looked at everything and made it better." - } - ] - }, - "contact": { - "slogan": "Lets 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..." - } - }, - "header": { - "Name": "parsa aghayi", - "Home": "home", - "AboutMe": "about Me", - "Services": "services", - "Projects": "projects", - "Testimonials": "testimonials", - "Contact": "contact", - "Blog": "blog", - "Button": "Resume" - }, - "footer": { - "Name": "parsa aghayi", - "Home": "home", - "AboutMe": "about Me", - "Services": "services", - "Projects": "projects", - "Testimonials": "testimonials", - "Contact": "contact", - "Blog": "blog", - "Year": "© 2024", - "CopyRight": "All Rights Reserved , Inc." - } + "website": { + "homePage": { + "top": { + "greeting": "Hi, I am", + "name": "Parsa Aghayi", + "profession": "Senior Frontend Engineer & Web Architect", + "roll": "Turning complex engineering challenges into clean, maintainable code.", + "descriptionAboutMe": "Crafting high-performance web applications, scalable React/Next.js architectures, and seamless backend integrations. Turning complex engineering challenges into clean, maintainable code.", + "cta": "Let's Work Together" + }, + "nav": { + "home": "home", + "aboutMe": "about Me", + "services": "services", + "projects": "projects", + "testimonials": "testimonials", + "contact": "contact", + "blog": "blog" + }, + "services": { + "title": "services", + "description": "In today's digital landscape, having a robust online presence is essential for businesses and individuals alike. Our services cater to a wide range of web development needs, ensuring that your project is functional, visually appealing, and user-friendly." + }, + "projects": { + "title": "my projects", + "description": "Explore a selection of my web development projects that showcase my ability to deliver high-quality solutions and create engaging digital experiences. See how I can help bring your vision to life!" + }, + "testimonials": { + "title": "testimonials", + "description": "The Testimonials section features feedback from clients and collaborators, highlighting the quality of my services and commitment to client satisfaction. These authentic reviews reflect my professionalism and the positive impact of my work, giving potential clients confidence in choosing me for their web development needs.", + "data": [ + { + "name": "Sarah Johnson", + "position": "Founder & CEO of Innovate Solutions", + "image": "/images/user-1.svg", + "quote": "Parsa rebuilt our corporate website from the ground up. Load times dropped by 60% and the new React/Next.js architecture made content updates effortless for our team. Conversion rates have been climbing steadily ever since launch." + }, + { + "name": "Michael Lee", + "position": "Chief Executive Officer at Tech Innovators", + "image": "/images/user-1.svg", + "quote": "What impressed me most was Parsa's clarity. He translated complex technical requirements into a clear roadmap, delivered on schedule, and documented everything so our own team could maintain the project independently." + }, + { + "name": "Emma Davis", + "position": "CEO & Lead Strategist at Visionary Ventures", + "image": "/images/user-1.svg", + "quote": "The attention to detail was outstanding. From responsive design to accessibility and SEO, every aspect of our platform felt thoughtful. Parsa genuinely invested time in understanding our business before writing a single line of code." + }, + { + "name": "John Doe", + "position": "COO at Startup Labs", + "image": "/images/user-1.svg", + "quote": "Our previous agency left us with an unstable product. Parsa took over, stabilized the codebase, and shipped the MVP we needed within a few weeks. Professional, communicative, and pragmatic from start to finish." + }, + { + "name": "Jane Smith", + "position": "Founder at Health Innovations", + "image": "/images/user-1.svg", + "quote": "Our web app handles sensitive user data, so security and reliability were non-negotiable. Parsa delivered a clean, secure architecture and was always quick to respond whenever we had questions." + }, + { + "name": "Alex Chen", + "position": "CTO at CloudBase Technologies", + "image": "/images/user-1.svg", + "quote": "Parsa is that rare engineer who cares about the whole product, not just the code. Backend integrations, deployment pipelines, performance — he looked at everything and made it better." + } + ] + }, + "contact": { + "slogan": "Lets 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..." + } }, - "blog": { - "homePage": { - "viewAll": "viewAll", - "new": "new", - "categories": "categories", - "popular": "popular", - "random": "random", - "by": "BY", - "in": "IN", - "readArticle": "Read article", - "newsletterTitle": "Get fresh articles in your inbox", - "newsletterText": "One useful engineering post per week. No spam, unsubscribe anytime.", - "subscribe": "Subscribe", - "readTime": "min read" - }, - "filteredPostsPage": { - "newTitle": "new", - "popularTitle": "popular", - "newDescription": "Explore the latest posts on our blog. Stay updated with fresh content, insightful articles, and the most recent discussions in your areas of interest.", - "popularDescription": "Discover the most popular posts with the highest views. These articles have resonated with our audience and are trending across various topics." - }, - "categoriesPage": { - "title": "categories", - "pageTitle": "all categories list", - "description": "Browse through our collection of categories to find posts on your favorite topics. Whether you`re looking for insightful articles, how-tos, or the latest trends, our categories make it easy to discover content tailored to your interests." - }, - "categoriySinglePage": { - "total": "total posts of " - }, - "postSinglePage": { - "followMe": "follow me", - "YouMightLike": "you might also like...", - "readTime": "min read", - "onThisPage": "On this page", - "share": "Share", - "copyLink": "Copy link", - "linkCopied": "Link copied", - "newerPost": "Newer post", - "olderPost": "Older post", - "commentsTitle": "Comments", - "leaveComment": "Leave a comment", - "commentName": "Name", - "commentEmail": "Email (optional)", - "commentBody": "Your comment", - "commentSubmit": "Post comment", - "commentPending": "Thanks! Your comment is awaiting approval.", - "noComments": "No comments yet — be the first.", - "commentError": "Something went wrong. Please try again.", - "likeButton": "Like this post" - }, - "header": { - "Home": "Home", - "New": "New", - "Popular": "Popular", - "Categories": "Categories", - "button": "subscribe" - }, - "footer": { - "Name": "parsa aghayi", - "Year": "© 2024", - "CopyRight": "All Rights Reserved , Inc." - }, - "pagination": { - "first": "first", - "last": "last" - } + "header": { + "Name": "parsa aghayi", + "Home": "home", + "AboutMe": "about Me", + "Services": "services", + "Projects": "projects", + "Testimonials": "testimonials", + "Contact": "contact", + "Blog": "blog", + "Button": "Resume" + }, + "footer": { + "Name": "parsa aghayi", + "Home": "home", + "AboutMe": "about Me", + "Services": "services", + "Projects": "projects", + "Testimonials": "testimonials", + "Contact": "contact", + "Blog": "blog", + "Year": "© 2024", + "CopyRight": "All Rights Reserved , Inc." } + }, + "blog": { + "homePage": { + "viewAll": "viewAll", + "new": "new", + "categories": "categories", + "popular": "popular", + "random": "random", + "by": "BY", + "in": "IN", + "readArticle": "Read article", + "newsletterTitle": "Get fresh articles in your inbox", + "newsletterText": "One useful engineering post per week. No spam, unsubscribe anytime.", + "subscribe": "Subscribe", + "readTime": "min read" + }, + "filteredPostsPage": { + "newTitle": "new", + "popularTitle": "popular", + "newDescription": "Explore the latest posts on our blog. Stay updated with fresh content, insightful articles, and the most recent discussions in your areas of interest.", + "popularDescription": "Discover the most popular posts with the highest views. These articles have resonated with our audience and are trending across various topics." + }, + "categoriesPage": { + "title": "categories", + "pageTitle": "all categories list", + "description": "Browse through our collection of categories to find posts on your favorite topics. Whether you`re looking for insightful articles, how-tos, or the latest trends, our categories make it easy to discover content tailored to your interests." + }, + "categoriySinglePage": { + "total": "total posts of " + }, + "postSinglePage": { + "followMe": "follow me", + "YouMightLike": "you might also like...", + "readTime": "min read", + "onThisPage": "On this page", + "share": "Share", + "copyLink": "Copy link", + "linkCopied": "Link copied", + "newerPost": "Newer post", + "olderPost": "Older post", + "commentsTitle": "Comments", + "leaveComment": "Leave a comment", + "commentName": "Name", + "commentEmail": "Email (optional)", + "commentBody": "Your comment", + "commentSubmit": "Post comment", + "commentPending": "Thanks! Your comment is awaiting approval.", + "noComments": "No comments yet — be the first.", + "commentError": "Something went wrong. Please try again.", + "likeButton": "Like this post" + }, + "header": { + "Home": "Home", + "New": "New", + "Popular": "Popular", + "Categories": "Categories", + "button": "subscribe", + "AllPosts": "All posts" + }, + "footer": { + "Name": "parsa aghayi", + "Year": "© 2024", + "CopyRight": "All Rights Reserved , Inc." + }, + "pagination": { + "first": "first", + "last": "last" + }, + "subscribeModal": { + "title": "Join the newsletter", + "text": "One useful engineering post per week. No spam, unsubscribe anytime.", + "email": "Email address", + "mobile": "Mobile number", + "submit": "Subscribe", + "note": "Your contact details are only used for the newsletter. At least an email or a mobile number is required.", + "success": "Thanks! You are now subscribed.", + "already": "You are already subscribed.", + "error": "Something went wrong. Please try again.", + "eitherRequired": "Enter at least an email or a mobile number.", + "close": "Close" + }, + "postsPage": { + "title": "All posts", + "description": "Every article published on the blog, newest first." + } + } } \ No newline at end of file diff --git a/src/app/lib/dictionaries/fa.json b/src/app/lib/dictionaries/fa.json index 3ad1f5f..5bcc1a0 100644 --- a/src/app/lib/dictionaries/fa.json +++ b/src/app/lib/dictionaries/fa.json @@ -1,169 +1,187 @@ { - "website": { - "homePage": { - "top": { - "greeting": "سلام، من", - "name": "پارسا آقایی", - "profession": "ارشد توسعه فرانت‌اند و معمار راهکارهای وب", - "roll": "تمرکز من بر خلق رابط‌های کاربری بسیار بهینه و توسعه کامپوننت‌های مقیاس‌پذیر است.", - "descriptionAboutMe": "با بیش از ۱۰ سال تجربه در دنیای توسعه وب، مسیر کاری من ترکیبی از مهندسی دقیق فرانت‌اند و درک عمیق از معماری بک‌اند است. تخصص اصلی من در بازطراحی و Refactor کدهای پیچیده، بهینه‌سازی Performance پروژه‌های بزرگ Next.js و پیاده‌سازی زیرساخت‌های پایدار وب است.", - "cta": "بیایید با هم کار کنیم" - }, - "nav": { - "home": "خانه", - "aboutMe": "درباره من", - "services": "خدمات", - "projects": "پروژه‌ها", - "testimonials": "نظرات", - "contact": "تماس", - "blog": "وبلاگ" - }, - "services": { - "title": "خدمات", - "description": "در چشم‌انداز دیجیتال امروز، داشتن یک حضور آنلاین قدرتمند برای کسب‌وکارها و افراد ضروری است. خدمات ما طیف گسترده‌ای از نیازهای توسعه وب را پوشش می‌دهد تا اطمینان حاصل شود که پروژه شما کاربردی، از نظر بصری جذاب و کاربرپسند است." - }, - "projects": { - "title": "پروژه‌های من", - "description": "مجموعه‌ای از پروژه‌های توسعه وب من را بررسی کنید که توانایی من در ارائه راهکارهای با کیفیت بالا و ایجاد تجربه‌های دیجیتال جذاب را نشان می‌دهد. ببینید چگونه می‌توانم به شما در تحقق چشم‌اندازتان کمک کنم!" - }, - "testimonials": { - "title": "نظرات", - "description": "بخش نظرات شامل بازخوردهای مشتریان و همکاران است که کیفیت خدمات و تعهد من به رضایت مشتری را برجسته می‌کند. این بررسی‌های واقعی، حرفه‌ای‌گری و تأثیر مثبت کارهای من را نشان می‌دهد و به مشتریان احتمالی اطمینان می‌دهد.", - "data": [ - { - "name": "سارا جانسون", - "position": "بنیان‌گذار و مدیرعامل راهکارهای نوآورانه", - "image": "/images/user-1.svg", - "quote": "پارسا وب‌سایت سازمانی ما را از پایه بازسازی کرد. زمان بارگذاری ۶۰٪ کاهش یافت و معماری جدید ری‌اکت و نکست به‌روزرسانی محتوا را برای تیم‌مان بسیار ساده کرد. نرخ تبدیل هم از همان ابتدای انتشار پیوسته در حال رشد است." - }, - { - "name": "مایکل لی", - "position": "مدیر اجرایی در نوآوران فناوری", - "image": "/images/user-1.svg", - "quote": "چیزی که بیش از همه مرا تحت تأثیر قرار داد شفافیت پارسا بود. او نیازهای پیچیده فنی را به یک نقشه راه مشخص تبدیل کرد، سر موعد تحویل داد و همه‌چیز را مستند کرد تا تیم خودمان بتواند به‌طور مستقل پروژه را نگهداری کند." - }, - { - "name": "اما دیویس", - "position": "مدیرعامل و استراتژیست ارشد در ونچرهای چشم‌انداز", - "image": "/images/user-1.svg", - "quote": "توجه به جزئیات فوق‌العاده بود. از طراحی واکنش‌گرا تا دسترس‌پذیری و سئو، همه جنبه‌های پلتفرم‌مان دقیق و حساب‌شده بود. پارسا پیش از نوشتن اولین خط کد، زمان واقعی برای درک کسب‌وکار ما صرف کرد." - }, - { - "name": "جان دو", - "position": "مدیر عملیات در استارتاپ لبز", - "image": "/images/user-1.svg", - "quote": "آژانس قبلی محصولی ناپایدار برای ما رها کرده بود. پارسا پروژه را تحویل گرفت، کد را سامان داد و نسخه اولیه (MVP) مورد نیازمان را ظرف چند هفته تحویل داد. از ابتدا تا انتها حرفه‌ای، خوش‌برخورد و عمل‌گرا بود." - }, - { - "name": "جین اسمیت", - "position": "بنیان‌گذار در نوآوری‌های سلامت", - "image": "/images/user-1.svg", - "quote": "اپلیکیشن ما با داده‌های حساس کاربری سروکار دارد، بنابراین امنیت و پایداری برای‌مان خط قرمز بود. پارسا معماری تمیز و امنی پیاده کرد و هر وقت سؤالی داشتیم سریع پاسخ می‌داد." - }, - { - "name": "الکس چن", - "position": "مدیر فناوری در فناوری‌های کلودبیس", - "image": "/images/user-1.svg", - "quote": "پارسا همان مهندس کمیابی است که به کل محصول اهمیت می‌دهد نه فقط کد. از یکپارچه‌سازی بک‌اند و پایپ‌لاین استقرار تا بهینه‌سازی عملکرد، به همه‌چیز نگاه کرد و آن را بهتر کرد." - } - ] - }, - "contact": { - "slogan": "بیایید با هم طراحی کنیم", - "description": "بخش تماس با من راهی ساده برای ارتباط جهت استعلامات، پیشنهادهای پروژه یا فرصت‌های همکاری است. فرم تماس را پر کنید یا از اطلاعات ارائه شده استفاده کنید و من سریعاً برای بحث درباره ایده‌های شما و نحوه کمک من پاسخ خواهم داد.", - "button": "تماس با من", - "placeholder": "آدرس ایمیل خود را اینجا وارد کنید..." - } - }, - "header": { - "Name": "پارسا آقایی", - "Home": "خانه", - "AboutMe": "درباره من", - "Services": "خدمات", - "Projects": "پروژه‌ها", - "Testimonials": "نظرات", - "Contact": "تماس", - "Blog": "وبلاگ", - "Button": "رزومه" - }, - "footer": { - "Name": "پارسا آقایی", - "Home": "خانه", - "AboutMe": "درباره من", - "Services": "خدمات", - "Projects": "پروژه‌ها", - "Testimonials": "نظرات", - "Contact": "تماس", - "Blog": "وبلاگ", - "Year": "© ۲۰۲۴", - "CopyRight": "تمامی حقوق محفوظ است" - } + "website": { + "homePage": { + "top": { + "greeting": "سلام، من", + "name": "پارسا آقایی", + "profession": "ارشد توسعه فرانت‌اند و معمار راهکارهای وب", + "roll": "تمرکز من بر خلق رابط‌های کاربری بسیار بهینه و توسعه کامپوننت‌های مقیاس‌پذیر است.", + "descriptionAboutMe": "با بیش از ۱۰ سال تجربه در دنیای توسعه وب، مسیر کاری من ترکیبی از مهندسی دقیق فرانت‌اند و درک عمیق از معماری بک‌اند است. تخصص اصلی من در بازطراحی و Refactor کدهای پیچیده، بهینه‌سازی Performance پروژه‌های بزرگ Next.js و پیاده‌سازی زیرساخت‌های پایدار وب است.", + "cta": "بیایید با هم کار کنیم" + }, + "nav": { + "home": "خانه", + "aboutMe": "درباره من", + "services": "خدمات", + "projects": "پروژه‌ها", + "testimonials": "نظرات", + "contact": "تماس", + "blog": "وبلاگ" + }, + "services": { + "title": "خدمات", + "description": "در چشم‌انداز دیجیتال امروز، داشتن یک حضور آنلاین قدرتمند برای کسب‌وکارها و افراد ضروری است. خدمات ما طیف گسترده‌ای از نیازهای توسعه وب را پوشش می‌دهد تا اطمینان حاصل شود که پروژه شما کاربردی، از نظر بصری جذاب و کاربرپسند است." + }, + "projects": { + "title": "پروژه‌های من", + "description": "مجموعه‌ای از پروژه‌های توسعه وب من را بررسی کنید که توانایی من در ارائه راهکارهای با کیفیت بالا و ایجاد تجربه‌های دیجیتال جذاب را نشان می‌دهد. ببینید چگونه می‌توانم به شما در تحقق چشم‌اندازتان کمک کنم!" + }, + "testimonials": { + "title": "نظرات", + "description": "بخش نظرات شامل بازخوردهای مشتریان و همکاران است که کیفیت خدمات و تعهد من به رضایت مشتری را برجسته می‌کند. این بررسی‌های واقعی، حرفه‌ای‌گری و تأثیر مثبت کارهای من را نشان می‌دهد و به مشتریان احتمالی اطمینان می‌دهد.", + "data": [ + { + "name": "سارا جانسون", + "position": "بنیان‌گذار و مدیرعامل راهکارهای نوآورانه", + "image": "/images/user-1.svg", + "quote": "پارسا وب‌سایت سازمانی ما را از پایه بازسازی کرد. زمان بارگذاری ۶۰٪ کاهش یافت و معماری جدید ری‌اکت و نکست به‌روزرسانی محتوا را برای تیم‌مان بسیار ساده کرد. نرخ تبدیل هم از همان ابتدای انتشار پیوسته در حال رشد است." + }, + { + "name": "مایکل لی", + "position": "مدیر اجرایی در نوآوران فناوری", + "image": "/images/user-1.svg", + "quote": "چیزی که بیش از همه مرا تحت تأثیر قرار داد شفافیت پارسا بود. او نیازهای پیچیده فنی را به یک نقشه راه مشخص تبدیل کرد، سر موعد تحویل داد و همه‌چیز را مستند کرد تا تیم خودمان بتواند به‌طور مستقل پروژه را نگهداری کند." + }, + { + "name": "اما دیویس", + "position": "مدیرعامل و استراتژیست ارشد در ونچرهای چشم‌انداز", + "image": "/images/user-1.svg", + "quote": "توجه به جزئیات فوق‌العاده بود. از طراحی واکنش‌گرا تا دسترس‌پذیری و سئو، همه جنبه‌های پلتفرم‌مان دقیق و حساب‌شده بود. پارسا پیش از نوشتن اولین خط کد، زمان واقعی برای درک کسب‌وکار ما صرف کرد." + }, + { + "name": "جان دو", + "position": "مدیر عملیات در استارتاپ لبز", + "image": "/images/user-1.svg", + "quote": "آژانس قبلی محصولی ناپایدار برای ما رها کرده بود. پارسا پروژه را تحویل گرفت، کد را سامان داد و نسخه اولیه (MVP) مورد نیازمان را ظرف چند هفته تحویل داد. از ابتدا تا انتها حرفه‌ای، خوش‌برخورد و عمل‌گرا بود." + }, + { + "name": "جین اسمیت", + "position": "بنیان‌گذار در نوآوری‌های سلامت", + "image": "/images/user-1.svg", + "quote": "اپلیکیشن ما با داده‌های حساس کاربری سروکار دارد، بنابراین امنیت و پایداری برای‌مان خط قرمز بود. پارسا معماری تمیز و امنی پیاده کرد و هر وقت سؤالی داشتیم سریع پاسخ می‌داد." + }, + { + "name": "الکس چن", + "position": "مدیر فناوری در فناوری‌های کلودبیس", + "image": "/images/user-1.svg", + "quote": "پارسا همان مهندس کمیابی است که به کل محصول اهمیت می‌دهد نه فقط کد. از یکپارچه‌سازی بک‌اند و پایپ‌لاین استقرار تا بهینه‌سازی عملکرد، به همه‌چیز نگاه کرد و آن را بهتر کرد." + } + ] + }, + "contact": { + "slogan": "بیایید با هم طراحی کنیم", + "description": "بخش تماس با من راهی ساده برای ارتباط جهت استعلامات، پیشنهادهای پروژه یا فرصت‌های همکاری است. فرم تماس را پر کنید یا از اطلاعات ارائه شده استفاده کنید و من سریعاً برای بحث درباره ایده‌های شما و نحوه کمک من پاسخ خواهم داد.", + "button": "تماس با من", + "placeholder": "آدرس ایمیل خود را اینجا وارد کنید..." + } }, - "blog": { - "homePage": { - "viewAll": "مشاهده همه", - "new": "جدیدترین‌ها", - "categories": "دسته‌بندی‌ها", - "popular": "محبوب‌ترین‌ها", - "random": "تصادفی", - "by": "توسط", - "in": "در", - "readArticle": "مطالعه مقاله", - "newsletterTitle": "مقاله‌های تازه را در ایمیل خود دریافت کنید", - "newsletterText": "هر هفته یک مقاله مفید درباره مهندسی نرم‌افزار. بدون اسپم، لغو اشتراک در هر زمان.", - "subscribe": "عضویت", - "readTime": "دقیقه مطالعه" - }, - "filteredPostsPage": { - "newTitle": "جدیدترین‌ها", - "popularTitle": "محبوب‌ترین‌ها", - "newDescription": "جدیدترین پست‌های وبلاگ ما را بررسی کنید. با محتوای تازه، مقالات بصیرت‌بخش و اخیرین بحث‌ها در زمینه‌های مورد علاقه خود به‌روز بمانید.", - "popularDescription": "محبوب‌ترین پست‌ها با بیشترین بازدید را کشف کنید. این مقالات با مخاطبان ما ارتباط برقرار کرده و در موضوعات مختلف ترند شده‌اند." - }, - "categoriesPage": { - "title": "دسته‌بندی‌ها", - "pageTitle": "لیست تمامی دسته‌بندی‌ها", - "description": "Browse through our collection of categories to find posts on your favorite topics. Whether you`re looking for insightful articles, how-tos, or the latest trends, our categories make it easy to discover content tailored to your interests." - }, - "categoriySinglePage": { - "total": "تعداد کل پست‌ها: " - }, - "postSinglePage": { - "followMe": "من را دنبال کنید", - "YouMightLike": "شاید این‌ها را هم بپسندید...", - "readTime": "دقیقه مطالعه", - "onThisPage": "فهرست مطالب", - "share": "اشتراک‌گذاری", - "copyLink": "کپی لینک", - "linkCopied": "لینک کپی شد", - "newerPost": "پست جدیدتر", - "olderPost": "پست قدیمی‌تر", - "commentsTitle": "دیدگاه‌ها", - "leaveComment": "ثبت دیدگاه", - "commentName": "نام", - "commentEmail": "ایمیل (اختیاری)", - "commentBody": "متن دیدگاه", - "commentSubmit": "ارسال دیدگاه", - "commentPending": "ممنون! دیدگاه شما پس از تأیید نمایش داده می‌شود.", - "noComments": "هنوز دیدگاهی ثبت نشده است. شما اولین نفر باشید.", - "commentError": "خطایی رخ داد. لطفاً دوباره تلاش کنید.", - "likeButton": "لایک کردن این پست" - }, - "header": { - "Home": "خانه", - "New": "جدیدترین‌ها", - "Popular": "محبوب‌ترین‌ها", - "Categories": "دسته‌بندی‌ها", - "button": "عضویت" - }, - "footer": { - "Name": "پارسا آقایی", - "Year": "© ۲۰۲۴", - "CopyRight": "تمامی حقوق محفوظ است" - }, - "pagination": { - "first": "اولین", - "last": "آخرین" - } + "header": { + "Name": "پارسا آقایی", + "Home": "خانه", + "AboutMe": "درباره من", + "Services": "خدمات", + "Projects": "پروژه‌ها", + "Testimonials": "نظرات", + "Contact": "تماس", + "Blog": "وبلاگ", + "Button": "رزومه" + }, + "footer": { + "Name": "پارسا آقایی", + "Home": "خانه", + "AboutMe": "درباره من", + "Services": "خدمات", + "Projects": "پروژه‌ها", + "Testimonials": "نظرات", + "Contact": "تماس", + "Blog": "وبلاگ", + "Year": "© ۲۰۲۴", + "CopyRight": "تمامی حقوق محفوظ است" } + }, + "blog": { + "homePage": { + "viewAll": "مشاهده همه", + "new": "جدیدترین‌ها", + "categories": "دسته‌بندی‌ها", + "popular": "محبوب‌ترین‌ها", + "random": "تصادفی", + "by": "توسط", + "in": "در", + "readArticle": "مطالعه مقاله", + "newsletterTitle": "مقاله‌های تازه را در ایمیل خود دریافت کنید", + "newsletterText": "هر هفته یک مقاله مفید درباره مهندسی نرم‌افزار. بدون اسپم، لغو اشتراک در هر زمان.", + "subscribe": "عضویت", + "readTime": "دقیقه مطالعه" + }, + "filteredPostsPage": { + "newTitle": "جدیدترین‌ها", + "popularTitle": "محبوب‌ترین‌ها", + "newDescription": "جدیدترین پست‌های وبلاگ ما را بررسی کنید. با محتوای تازه، مقالات بصیرت‌بخش و اخیرین بحث‌ها در زمینه‌های مورد علاقه خود به‌روز بمانید.", + "popularDescription": "محبوب‌ترین پست‌ها با بیشترین بازدید را کشف کنید. این مقالات با مخاطبان ما ارتباط برقرار کرده و در موضوعات مختلف ترند شده‌اند." + }, + "categoriesPage": { + "title": "دسته‌بندی‌ها", + "pageTitle": "لیست تمامی دسته‌بندی‌ها", + "description": "Browse through our collection of categories to find posts on your favorite topics. Whether you`re looking for insightful articles, how-tos, or the latest trends, our categories make it easy to discover content tailored to your interests." + }, + "categoriySinglePage": { + "total": "تعداد کل پست‌ها: " + }, + "postSinglePage": { + "followMe": "من را دنبال کنید", + "YouMightLike": "شاید این‌ها را هم بپسندید...", + "readTime": "دقیقه مطالعه", + "onThisPage": "فهرست مطالب", + "share": "اشتراک‌گذاری", + "copyLink": "کپی لینک", + "linkCopied": "لینک کپی شد", + "newerPost": "پست جدیدتر", + "olderPost": "پست قدیمی‌تر", + "commentsTitle": "دیدگاه‌ها", + "leaveComment": "ثبت دیدگاه", + "commentName": "نام", + "commentEmail": "ایمیل (اختیاری)", + "commentBody": "متن دیدگاه", + "commentSubmit": "ارسال دیدگاه", + "commentPending": "ممنون! دیدگاه شما پس از تأیید نمایش داده می‌شود.", + "noComments": "هنوز دیدگاهی ثبت نشده است. شما اولین نفر باشید.", + "commentError": "خطایی رخ داد. لطفاً دوباره تلاش کنید.", + "likeButton": "لایک کردن این پست" + }, + "header": { + "Home": "خانه", + "New": "جدیدترین‌ها", + "Popular": "محبوب‌ترین‌ها", + "Categories": "دسته‌بندی‌ها", + "button": "عضویت", + "AllPosts": "همه مطالب" + }, + "footer": { + "Name": "پارسا آقایی", + "Year": "© ۲۰۲۴", + "CopyRight": "تمامی حقوق محفوظ است" + }, + "pagination": { + "first": "اولین", + "last": "آخرین" + }, + "subscribeModal": { + "title": "عضویت در خبرنامه", + "text": "هر هفته یک مقاله مفید درباره مهندسی نرمافزار. بدون اسپم، لغو اشتراک در هر زمان.", + "email": "ایمیل", + "mobile": "شماره موبایل", + "submit": "عضویت", + "note": "اطلاعات شما فقط برای ارسال خبرنامه استفاده میشود. حداقل یکی از ایمیل یا شماره موبایل الزامی است.", + "success": "عضویت شما با موفقیت ثبت شد.", + "already": "شما قبلاً در خبرنامه عضویت داشتهاید.", + "error": "خطایی رخ داد. لطفاً دوباره تلاش کنید.", + "eitherRequired": "حداقل ایمیل یا شماره موبایل را وارد کنید.", + "close": "بستن" + }, + "postsPage": { + "title": "همه مطالب", + "description": "همه مقالات منتشرشده در وبلاگ، از جدیدترین به قدیمیترین." + } + } } \ No newline at end of file diff --git a/src/app/lib/functions/formatDate.ts b/src/app/lib/functions/formatDate.ts new file mode 100644 index 0000000..5583b7f --- /dev/null +++ b/src/app/lib/functions/formatDate.ts @@ -0,0 +1,23 @@ +/** + * Locale-aware date label for the bilingual blog. + * + * Persian readers see the Jalali (Shamsi) calendar with Persian digits, English + * readers get the Gregorian calendar. Values may arrive as an ISO timestamp or + * as the short English string the API composes ("Oct 03 2026"), so an unparsable + * string is echoed back instead of breaking the layout. + */ +export function formatDate(value: unknown, locale: string): string { + if (typeof value !== "string" || value.trim() === "") { + return ""; + } + + const parsed = new Date(value.trim()); + + if (Number.isNaN(parsed.getTime())) { + return value.trim(); + } + + return new Intl.DateTimeFormat(locale === "fa" ? "fa-IR" : "en-US", { + dateStyle: "medium", + }).format(parsed); +} \ No newline at end of file diff --git a/src/app/types/types.ts b/src/app/types/types.ts index 5c87179..982c377 100644 --- a/src/app/types/types.ts +++ b/src/app/types/types.ts @@ -256,8 +256,26 @@ export type Dictionary = { New: string; Popular: string; Categories: string; + AllPosts: string; button: string; }; + subscribeModal: { + title: string; + text: string; + email: string; + mobile: string; + submit: string; + note: string; + success: string; + already: string; + error: string; + eitherRequired: string; + close: string; + }; + postsPage: { + title: string; + description: string; + }; footer: { Name: string; Year: string;