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 (
+
+
{post.title}
@@ -93,7 +185,9 @@ export default async function SinglePost(props: PostSlugPagepropsType) {
{dict.blog.homePage.by}
{authorName}
diff --git a/src/app/(routes)/blog/tags/[slug]/page.tsx b/src/app/(routes)/blog/tags/[slug]/page.tsx
index 5c2869d..1596318 100644
--- a/src/app/(routes)/blog/tags/[slug]/page.tsx
+++ b/src/app/(routes)/blog/tags/[slug]/page.tsx
@@ -1,8 +1,148 @@
-type propsType = {
- params: Promise<{ slug: string }>;
-};
+import {
+ tagSlugPropsType,
+ TagDataType,
+} from "@/app/types/types";
+import { Metadata } from "next";
+import Image from "next/image";
+import Link from "next/link";
+import { redirect } from "next/navigation";
+import NoDataFounded from "../../components/no-data-founded/noDataFounded";
+import Pagination from "../../components/pagination/pagination";
+import { getDictionary } from "@/app/lib/functions/dictionaries";
+import { getDefaultLocale } from "@/app/lib/functions/utils";
-export default async function SingleTag(props: propsType) {
- const params = await props.params;
- return
{params.slug}
;
+async function fetchTagData(
+ slug: string,
+ searchParams: URLSearchParams,
+): Promise {
+ 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")}` : ""}`,
+ {
+ cache: process.env.NEXT_PUBLIC_BLOG_CACHE ? "force-cache" : "no-store",
+ },
+ );
+
+ if (res.status === 404) {
+ redirect("/blog/404");
+ }
+
+ return res.json();
}
+
+export async function generateMetadata(props: tagSlugPropsType): Promise {
+ const params = await props.params;
+ const tagData: TagDataType = await fetchTagData(
+ params.slug,
+ new URLSearchParams(),
+ );
+
+ return {
+ title: tagData.tag.name,
+ description: `Posts tagged with "${tagData.tag.name}" on Parsa Aghayi's blog.`,
+ };
+}
+
+export default async function SingleTag(props: tagSlugPropsType) {
+ const searchParams = await props.searchParams;
+ const params = await props.params;
+ const dict = await getDictionary(await getDefaultLocale());
+
+ const tagData: TagDataType = await fetchTagData(
+ params.slug,
+ new URLSearchParams(searchParams as Record),
+ );
+
+ const tagName = tagData.tag.name || params.slug.replaceAll(/%20|-|_/g, " ");
+
+ return (
+
+
+
+ {tagName}
+
+
+
+
+ {dict.blog.categoriySinglePage.total}
+ {tagName}
+
+
+ {tagData.meta.total}
+
+
+
+
+
+
+ -
+
+ {dict.blog.header.Home}
+
+
+ -
+
+
+ -
+
+ {tagName}
+
+
+
+
+
+ {tagData.posts.length > 0 ? (
+ tagData.posts.map((post) => (
+
+
+
+
+
+ {dict.blog.homePage.by}
+
+
+ {post.author.name}
+
+
+
+
+ {post.title}
+
+
+ {post.excerpt}
+
+
+ ))
+ ) : (
+
+ )}
+
+ {tagData.posts.length > 0 && tagData.meta.last_page > 1 && (
+
+ )}
+
+
+ );
+}
\ No newline at end of file
diff --git a/src/app/lib/site-config.ts b/src/app/lib/site-config.ts
new file mode 100644
index 0000000..a7321ff
--- /dev/null
+++ b/src/app/lib/site-config.ts
@@ -0,0 +1,13 @@
+export const SITE_URL = (
+ process.env.NEXT_PUBLIC_FRONT_URL || "https://parsaaghayi.ir"
+).replace(/\/+$/, "");
+
+export const SITE_NAME = "پارسا آقایی";
+export const SITE_NAME_EN = "Parsa Aghayi";
+
+export const SITE_DESCRIPTION =
+ "وبسایت شخصی پارسا آقایی، توسعهدهنده ارشد فرانتاند و معمار وب. مقالات تخصصی در حوزه React، Next.js، TypeScript، بهینهسازی سرعت و معماری نرمافزار، بههمراه معرفی خدمات و پروژهها.";
+
+export function ogImageUrl(text: string): string {
+ return `${SITE_URL}/og-image?text=${encodeURIComponent(text)}`;
+}
\ No newline at end of file
diff --git a/src/app/sitemap.ts b/src/app/sitemap.ts
index 9ebeb1d..7036e6b 100644
--- a/src/app/sitemap.ts
+++ b/src/app/sitemap.ts
@@ -1,5 +1,5 @@
import type { MetadataRoute } from 'next';
-import type { CategoryType, PostType } from './types/types';
+import type { CategoryType, PostType, TagType } from './types/types';
export const dynamic = 'force-dynamic';
@@ -11,6 +11,7 @@ const PER_PAGE = 50;
// Upper bound on pagination so a huge blog cannot stall the sitemap.
const MAX_POST_PAGES = 20;
const MAX_CATEGORY_PAGES = 4;
+const MAX_TAG_PAGES = 4;
type Paginated = {
data?: T[];
@@ -23,6 +24,7 @@ type Paginated = {
type SitemapPost = Pick;
type SitemapCategory = Pick;
+type SitemapTag = Pick;
function absoluteUrl(path: string): string {
return `${FRONT_URL}${path}`;
@@ -108,6 +110,24 @@ export default async function sitemap(): Promise {
changeFrequency: 'weekly',
priority: 0.7,
},
+ {
+ url: absoluteUrl('/blog/filtered-posts/new'),
+ lastModified: now,
+ changeFrequency: 'daily',
+ priority: 0.6,
+ },
+ {
+ url: absoluteUrl('/blog/filtered-posts/popular'),
+ lastModified: now,
+ changeFrequency: 'daily',
+ priority: 0.6,
+ },
+ {
+ url: absoluteUrl('/blog/posts'),
+ lastModified: now,
+ changeFrequency: 'daily',
+ priority: 0.6,
+ },
{
url: absoluteUrl('/projects'),
lastModified: now,
@@ -117,9 +137,10 @@ export default async function sitemap(): Promise {
];
try {
- const [posts, categories] = await Promise.all([
+ const [posts, categories, tags] = await Promise.all([
fetchAllPages('/posts', MAX_POST_PAGES),
fetchAllPages('/categories', MAX_CATEGORY_PAGES),
+ fetchAllPages('/tags', MAX_TAG_PAGES),
]);
const postRoutes: MetadataRoute.Sitemap = posts
@@ -143,7 +164,15 @@ export default async function sitemap(): Promise {
priority: 0.6,
}));
- return [...staticRoutes, ...postRoutes, ...categoryRoutes];
+ const tagRoutes: MetadataRoute.Sitemap = tags
+ .filter((tag) => typeof tag?.slug === 'string' && tag.slug.trim() !== '')
+ .map((tag) => ({
+ url: absoluteUrl(`/blog/tags/${tag.slug}`),
+ changeFrequency: 'weekly',
+ priority: 0.5,
+ }));
+
+ return [...staticRoutes, ...postRoutes, ...categoryRoutes, ...tagRoutes];
} catch {
// A sitemap must never take the site down: fall back to static routes only.
return staticRoutes;
diff --git a/src/app/types/types.ts b/src/app/types/types.ts
index 8cb1ee8..a41846a 100644
--- a/src/app/types/types.ts
+++ b/src/app/types/types.ts
@@ -78,6 +78,18 @@ export type CategoryDataType = {
links: LinksType;
};
+export type tagSlugPropsType = {
+ params: { slug: string };
+ searchParams: SearchParams;
+};
+
+export type TagDataType = {
+ tag: TagType;
+ posts: PostType[];
+ meta: MetaType;
+ links: LinksType;
+};
+
export type FilteredPostsPagepropsType = {
params: { filter: string };
searchParams: SearchParams;