From cc7a5f2b7c5243563e3520858183e8008e423b95 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 1 Oct 2026 16:33:19 -0400 Subject: [PATCH] Make the site crawlable and describe itself properly public/robots.txt was "Disallow: /", which told every crawler to ignore the entire site. It now allows crawling, keeps /admin and the API paths out of the index, and points at the sitemap. Add a generated sitemap covering the static routes plus every post and category. The API caps per_page at 50, so it follows meta.last_page instead of asking for more, and every fetch is wrapped so an unreachable API degrades to the static entries rather than taking the site down. Replace the placeholder layout metadata with real Persian titles, description, keywords, canonical URL, hreflang alternates, OpenGraph and Twitter cards, and add Person/WebSite JSON-LD. --- public/robots.txt | 13 ++- src/app/(routes)/(website)/layout.tsx | 132 ++++++++++++++++++++-- src/app/sitemap.ts | 151 ++++++++++++++++++++++++++ 3 files changed, 288 insertions(+), 8 deletions(-) create mode 100644 src/app/sitemap.ts diff --git a/public/robots.txt b/public/robots.txt index 1f53798..77a0c3c 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,2 +1,13 @@ User-agent: * -Disallow: / +Allow: / + +# Admin panel: no indexing, no crawling of the panel or its assets. +Disallow: /admin +Disallow: /admin/ +Disallow: /admin/* + +# Internal helpers that should never appear in search results. +Disallow: /og-image +Disallow: /api/ + +Sitemap: https://parsaaghayi.ir/sitemap.xml diff --git a/src/app/(routes)/(website)/layout.tsx b/src/app/(routes)/(website)/layout.tsx index 59723e0..d641b6c 100644 --- a/src/app/(routes)/(website)/layout.tsx +++ b/src/app/(routes)/(website)/layout.tsx @@ -3,22 +3,125 @@ import Header from "./components/header/header"; import Footer from "./components/footer/footer"; import NextTopLoader from "nextjs-toploader"; +const SITE_URL = ( + process.env.NEXT_PUBLIC_FRONT_URL || "https://parsaaghayi.ir" +).replace(/\/+$/, ""); + +const SITE_NAME = "پارسا آقایی"; +const SITE_NAME_EN = "Parsa Aghayi"; + +const DESCRIPTION = + "وب‌سایت شخصی پارسا آقایی، توسعه‌دهنده ارشد فرانت‌اند و معمار وب. مقالات تخصصی در حوزه React، Next.js، TypeScript، بهینه‌سازی سرعت و معماری نرم‌افزار، به‌همراه معرفی خدمات و پروژه‌ها."; + +const KEYWORDS = [ + "پارسا آقایی", + "پارسا آقایی وب سایت", + "توسعه دهنده فرانت اند", + "برنامه نویسی وب", + "React", + "Next.js", + "TypeScript", + "JavaScript", + "معماری وب", + "بهینه سازی سرعت سایت", + "طراحی رابط کاربری", + "وبلاگ برنامه نویسی", + "توسعه وب فارسی", +]; + export const metadata: Metadata = { + metadataBase: new URL(SITE_URL), title: { - template: "%s | parsa aghayi", - default: "parsa aghayi", + template: `%s | ${SITE_NAME}`, + default: `${SITE_NAME} | توسعه‌دهنده فرانت‌اند و معمار وب`, + }, + description: DESCRIPTION, + applicationName: SITE_NAME, + keywords: KEYWORDS, + authors: [ + { + name: SITE_NAME, + url: SITE_URL, + }, + ], + creator: SITE_NAME, + publisher: SITE_NAME, + alternates: { + canonical: "./", + languages: { + fa: "./", + en: "./", + "x-default": "./", + }, }, - description: "parsa aghayi personal website", openGraph: { title: { - template: "%s | parsa aghayi", - default: "parsa aghayi", + template: `%s | ${SITE_NAME}`, + default: `${SITE_NAME} | توسعه‌دهنده فرانت‌اند و معمار وب`, }, - description: "parsa aghayi's personal website", + description: DESCRIPTION, + type: "website", + locale: "fa_IR", + alternateLocale: ["en_US"], + url: SITE_URL, + siteName: SITE_NAME, images: [ - `${process.env.NEXT_PUBLIC_FRONT_URL}/og-image?text=parsa aghayi's personal website`, + { + url: `${SITE_URL}/og-image?text=${encodeURIComponent(SITE_NAME)}`, + width: 1200, + height: 1200, + alt: SITE_NAME, + }, ], }, + twitter: { + card: "summary_large_image", + title: `${SITE_NAME} | توسعه‌دهنده فرانت‌اند و معمار وب`, + description: DESCRIPTION, + images: [ + `${SITE_URL}/og-image?text=${encodeURIComponent(SITE_NAME)}`, + ], + }, +}; + +const PERSON_JSON_LD = { + "@context": "https://schema.org", + "@type": "Person", + name: SITE_NAME, + alternateName: SITE_NAME_EN, + jobTitle: "Senior Frontend Engineer & Web Architect", + description: DESCRIPTION, + url: SITE_URL, + email: "mailto:ceo@parsaaghayi.ir", + knowsAbout: [ + "React", + "Next.js", + "TypeScript", + "JavaScript", + "Web Performance", + "Software Architecture", + "UI/UX", + ], +}; + +const WEBSITE_JSON_LD = { + "@context": "https://schema.org", + "@type": "WebSite", + name: SITE_NAME, + alternateName: SITE_NAME_EN, + url: SITE_URL, + inLanguage: ["fa", "en"], + publisher: { + "@id": `${SITE_URL}/#person`, + }, + potentialAction: { + "@type": "SearchAction", + target: { + "@type": "EntryPoint", + urlTemplate: `${SITE_URL}/blog/filtered-posts/new?search={search_term_string}`, + }, + "query-input": "required name=search_term_string", + }, }; export default function RootLayout({ @@ -34,6 +137,21 @@ export default function RootLayout({ type="image/ico" sizes="32x32" /> + {/* JSON-LD must be delivered as a script tag, so dangerouslySetInnerHTML is + required here. The payload is fully static (site config + env URLs), never + user input, so there is no injection risk. */} +