From 32a7481ef638ab9c4bb4aaa0bae161aae1683c99 Mon Sep 17 00:00:00 2001 From: Parsa Aghayi Date: Fri, 2 Oct 2026 06:48:55 -0400 Subject: [PATCH] Complete SEO metadata, JSON-LD, real tag/projects pages, OG fallback fixes --- robots.txt | 2 - src/app/(routes)/(website)/(home)/page.tsx | 9 +- .../components/burger-button/burgerButton.tsx | 6 +- src/app/(routes)/(website)/projects/page.tsx | 45 +++++- src/app/(routes)/blog/categories/page.tsx | 5 +- .../components/burger-button/burgerButton.tsx | 6 +- .../blog/filtered-posts/[filter]/page.tsx | 4 +- src/app/(routes)/blog/layout.tsx | 50 ++++-- .../(routes)/blog/posts/[postSlug]/page.tsx | 98 ++++++++++- src/app/(routes)/blog/tags/[slug]/page.tsx | 152 +++++++++++++++++- src/app/lib/site-config.ts | 13 ++ src/app/sitemap.ts | 35 +++- src/app/types/types.ts | 12 ++ 13 files changed, 397 insertions(+), 40 deletions(-) delete mode 100644 robots.txt create mode 100644 src/app/lib/site-config.ts diff --git a/robots.txt b/robots.txt deleted file mode 100644 index 1f53798..0000000 --- a/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Disallow: / diff --git a/src/app/(routes)/(website)/(home)/page.tsx b/src/app/(routes)/(website)/(home)/page.tsx index 80c472e..f05edcf 100644 --- a/src/app/(routes)/(website)/(home)/page.tsx +++ b/src/app/(routes)/(website)/(home)/page.tsx @@ -7,6 +7,7 @@ import Hero from "../components/hero/hero"; import { getDictionary } from "@/app/lib/functions/dictionaries"; import { getDefaultLocale } from "@/app/lib/functions/utils"; 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! ;)"; @@ -17,7 +18,13 @@ export const metadata: Metadata = { openGraph: { title: "Parsa Aghayi's Personal Website", description, - images: [`${process.env.NEXT_PUBLIC_FRONT_URL}/images/profile.png`], + images: [`${SITE_URL}/images/profile.png`], + }, + twitter: { + card: "summary_large_image", + title: "Parsa Aghayi's Personal Website", + description, + images: [ogImageUrl("Parsa Aghayi")], }, }; diff --git a/src/app/(routes)/(website)/components/burger-button/burgerButton.tsx b/src/app/(routes)/(website)/components/burger-button/burgerButton.tsx index f293078..06ef125 100644 --- a/src/app/(routes)/(website)/components/burger-button/burgerButton.tsx +++ b/src/app/(routes)/(website)/components/burger-button/burgerButton.tsx @@ -16,14 +16,16 @@ export default function BurgerButton({ dict }: BurgerButtonProps) { diff --git a/src/app/(routes)/(website)/projects/page.tsx b/src/app/(routes)/(website)/projects/page.tsx index c6c9822..ad255df 100644 --- a/src/app/(routes)/(website)/projects/page.tsx +++ b/src/app/(routes)/(website)/projects/page.tsx @@ -1,15 +1,44 @@ 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"; +import Projects from "../components/projects/projects"; export const metadata: Metadata = { - title: "projects", - description: "parsa aghayi personal website projects description", + title: "Projects | Parsa Aghayi", + description: + "Explore a selection of Parsa Aghayi's web development projects: high-performance React and Next.js applications, custom interfaces and full-stack builds.", openGraph: { - title: "parsa aghayi personal website projects page title", - description: "parsa aghayi personal website projects description", - images: [`${process.env.NEXT_PUBLIC_FRONT_URL}/og-image?text=parsa aghayi's projects`], + title: "Parsa Aghayi's Projects", + description: + "A selection of high-performance React and Next.js projects built by Parsa Aghayi.", + images: [ogImageUrl("Parsa Aghayi's Projects")], + }, + twitter: { + card: "summary_large_image", + title: "Parsa Aghayi's Projects", + description: + "A selection of high-performance React and Next.js projects built by Parsa Aghayi.", + images: [ogImageUrl("Parsa Aghayi's Projects")], }, }; -export default function Projects() { - return
Projects
; -} +export default async function ProjectsPage() { + const dict = await getDictionary(await getDefaultLocale()); + + return ( +
+
+
+

+ {dict.website.homePage.projects.title} +

+

+ {dict.website.homePage.projects.description} +

+
+ +
+
+ ); +} \ No newline at end of file diff --git a/src/app/(routes)/blog/categories/page.tsx b/src/app/(routes)/blog/categories/page.tsx index 0c67ff5..663a025 100644 --- a/src/app/(routes)/blog/categories/page.tsx +++ b/src/app/(routes)/blog/categories/page.tsx @@ -10,6 +10,7 @@ import NoDataFounded from "../components/no-data-founded/noDataFounded"; 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"; export const metadata: Metadata = { title: "All Categories List", @@ -19,9 +20,7 @@ export const metadata: Metadata = { title: "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.", - images: [ - `${process.env.NEXT_PUBLIC_FRONT_URL}/og-image?text=All Categories List`, - ], + images: [ogImageUrl("All Categories List")], }, }; diff --git a/src/app/(routes)/blog/components/burger-button/burgerButton.tsx b/src/app/(routes)/blog/components/burger-button/burgerButton.tsx index ecb2843..0ce3834 100644 --- a/src/app/(routes)/blog/components/burger-button/burgerButton.tsx +++ b/src/app/(routes)/blog/components/burger-button/burgerButton.tsx @@ -10,14 +10,16 @@ export default function BurgerButton() { diff --git a/src/app/(routes)/blog/filtered-posts/[filter]/page.tsx b/src/app/(routes)/blog/filtered-posts/[filter]/page.tsx index 46e1dd8..e3f8499 100644 --- a/src/app/(routes)/blog/filtered-posts/[filter]/page.tsx +++ b/src/app/(routes)/blog/filtered-posts/[filter]/page.tsx @@ -10,6 +10,7 @@ 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"; type FilterKey = "new" | "popular"; @@ -53,8 +54,7 @@ const getFilterKey = (filter: string): FilterKey | null => { return normalized in FILTERS ? (normalized as FilterKey) : null; }; -const ogImage = (text: string) => - `${process.env.NEXT_PUBLIC_FRONT_URL}/og-image?text=${encodeURIComponent(text)}`; +const ogImage = (text: string) => ogImageUrl(text); export async function generateMetadata( props: FilteredPostsPagepropsType, diff --git a/src/app/(routes)/blog/layout.tsx b/src/app/(routes)/blog/layout.tsx index 4af3701..de0d439 100644 --- a/src/app/(routes)/blog/layout.tsx +++ b/src/app/(routes)/blog/layout.tsx @@ -2,23 +2,55 @@ import type { Metadata } from "next"; import Header from "./components/header/header"; import Footer from "./components/footer/footer"; import NextTopLoader from "nextjs-toploader"; +import { SITE_NAME, SITE_NAME_EN, SITE_URL, ogImageUrl } from "@/app/lib/site-config"; + +const BLOG_TITLE = `${SITE_NAME_EN}'s Blog`; export const metadata: Metadata = { + metadataBase: new URL(SITE_URL), title: { - template: "%s | parsa aghayi's blog", - default: "parsa aghayi's blog", + template: `%s | ${BLOG_TITLE}`, + default: BLOG_TITLE, }, - description: "parsa aghayi personal blog", - openGraph: { - title: { - template: "%s | parsa aghayi's blog", - default: "parsa aghayi's blog", + description: + `${SITE_NAME_EN}'s blog: practical articles about React, Next.js, TypeScript, web performance and frontend engineering, written in English and Persian.`, + alternates: { + canonical: "/blog", + languages: { + en: "/blog", + fa: "/blog", + "x-default": "/blog", }, - description: "parsa aghayi personal blog", + }, + openGraph: { + type: "website", + url: `${SITE_URL}/blog`, + siteName: SITE_NAME, + title: { + template: `%s | ${BLOG_TITLE}`, + default: BLOG_TITLE, + }, + description: `${SITE_NAME_EN}'s blog: practical frontend engineering articles in English and Persian.`, + locale: "en_US", + alternateLocale: ["fa_IR"], images: [ - `${process.env.NEXT_PUBLIC_FRONT_URL}/og-image?text=parsa aghayi's personal blog`, + { + url: ogImageUrl(`${SITE_NAME_EN}'s Blog`), + width: 1200, + height: 630, + alt: BLOG_TITLE, + }, ], }, + twitter: { + card: "summary_large_image", + title: { + template: `%s | ${BLOG_TITLE}`, + default: BLOG_TITLE, + }, + description: `${SITE_NAME_EN}'s blog: practical frontend engineering articles.`, + images: [ogImageUrl(`${SITE_NAME_EN}'s Blog`)], + }, }; export default function RootLayout({ diff --git a/src/app/(routes)/blog/posts/[postSlug]/page.tsx b/src/app/(routes)/blog/posts/[postSlug]/page.tsx index 4ff19f0..fecc73f 100644 --- a/src/app/(routes)/blog/posts/[postSlug]/page.tsx +++ b/src/app/(routes)/blog/posts/[postSlug]/page.tsx @@ -12,6 +12,7 @@ import { redirect } from "next/navigation"; import { renderBody } from "./body"; import { getCoverImageSrc } from "./coverImage"; import { AUTHOR_PROFILE_URL } from "@/app/lib/social-links"; +import { SITE_NAME, SITE_NAME_EN, SITE_URL } from "@/app/lib/site-config"; async function fetchPostData(postSlug: string): Promise { const res = await fetch( @@ -48,14 +49,44 @@ export async function generateMetadata(props: PostSlugPagepropsType): Promise 0 + ? { tags: post.post.tags.map((t) => t.name ?? String(t)) } + : {}), + }, + twitter: { + card: "summary_large_image", + title: post.post.title, + description: post.post.excerpt, + images: [ogImage.url], }, }; } @@ -75,8 +106,69 @@ export default async function SinglePost(props: PostSlugPagepropsType) { ? postData.related_posts : []; + const pageUrl = `${SITE_URL}/blog/posts/${post.slug ?? params.postSlug}`; + const articleJsonLd: Record = { + "@context": "https://schema.org", + "@type": "Article", + headline: post.title, + description: post.excerpt ?? undefined, + ...(coverImage ? { image: coverImage } : {}), + datePublished: post.published_at ?? undefined, + dateModified: post.updated_at ?? post.published_at ?? undefined, + author: { + "@type": "Person", + name: authorName || SITE_NAME_EN, + url: AUTHOR_PROFILE_URL, + }, + publisher: { + "@type": "Person", + name: SITE_NAME_EN, + url: SITE_URL, + }, + mainEntityOfPage: pageUrl, + }; + const breadcrumbJsonLd: Record = { + "@context": "https://schema.org", + "@type": "BreadcrumbList", + itemListElement: [ + { + "@type": "ListItem", + position: 1, + name: "Blog", + item: `${SITE_URL}/blog`, + }, + ...(categoryName && categorySlug + ? [ + { + "@type": "ListItem", + position: 2, + name: categoryName, + item: `${SITE_URL}/blog/categories/${categorySlug}`, + }, + ] + : []), + { + "@type": "ListItem", + position: categoryName && categorySlug ? 3 : 2, + name: post.title, + }, + ], + }; + return (
+