From 5818c895cd7358f67c83104ee0901d9f9c8285e7 Mon Sep 17 00:00:00 2001 From: ahasani194 Date: Mon, 16 Jun 2025 14:27:41 +0330 Subject: [PATCH] feat: add metadata for SEO optimization in English and Persian message files --- messages/en.d.json.ts | 23 +++++++++++++++-------- messages/en.json | 23 +++++++++++++++-------- messages/fa.json | 21 ++++++++++++++------- src/app/[locale]/layout.tsx | 25 +++++++++++++++++++++++++ src/config.ts | 2 +- 5 files changed, 70 insertions(+), 24 deletions(-) diff --git a/messages/en.d.json.ts b/messages/en.d.json.ts index 932aec4..07bdb07 100644 --- a/messages/en.d.json.ts +++ b/messages/en.d.json.ts @@ -2,6 +2,13 @@ // See: https://next-intl.dev/docs/workflows/typescript#messages-arguments declare const messages: { + "meta": { + "defaultTitle": "Pasargad Brick Company", + "titleTemplate": "%s | Pasargad Brick Company", + "defaultDescription": "Pasargad Brick Company", + "siteName": "Pasargad Brick Company" + }, + "pages_home_title": "Home", "pages_home_description": "Welcome to the home page", "pages_about_title": "About Us", @@ -93,28 +100,28 @@ declare const messages: { "pages_notFound_description": "You can either head back to the Homepage or try a search.", "pages_notFound_button": "Go To Home", - "page_about_metadata_title": "About Us - Brick Factory", + "page_about_metadata_title": "About Us", "page_about_metadata_description": "Learn more about our commitment to producing high-quality bricks using both traditional and modern manufacturing techniques.", - "page_home_metadata_title": "Home - Brick Factory", + "page_home_metadata_title": "Home", "page_home_metadata_description": "Welcome to our official website, where we showcase our expertise, quality, and innovation in brick manufacturing.", - "page_contact_metadata_title": "Contact Us - Brick Factory", + "page_contact_metadata_title": "Contact Us", "page_contact_metadata_description": "Get in touch with us for more information or to place an order. Our team is here to support your building needs.", - "page_products_metadata_title": "Products - Brick Factory", + "page_products_metadata_title": "Products", "page_products_metadata_description": "Explore our variety of traditional and industrial bricks designed to meet the demands of different construction projects.", - "page_blog_metadata_title": "Blog - Brick Factory", + "page_blog_metadata_title": "Blog", "page_blog_metadata_description": "Stay informed with our latest articles, news, and tips related to bricks and building materials.", - "page_projects_metadata_title": "Projects - Brick Factory", + "page_projects_metadata_title": "Projects", "page_projects_metadata_description": "Discover successful projects completed using our high-quality bricks and expert craftsmanship.", - "page_product_categories_metadata_title": "Product Categories - Brick Factory", + "page_product_categories_metadata_title": "Product Categories", "page_product_categories_metadata_description": "Browse through our product categories including Ghazaghi, yellow bricks, facing bricks, and more to find the right solution for your project.", - "page_not_found_metadata_title": "404 Not Found - Brick Factory", + "page_not_found_metadata_title": "404 Not Found", "page_not_found_metadata_description": "The page you are looking for doesn’t exist. You can return to the homepage or search for what you need." }; export default messages; \ No newline at end of file diff --git a/messages/en.json b/messages/en.json index 2160264..69e819a 100644 --- a/messages/en.json +++ b/messages/en.json @@ -1,4 +1,11 @@ { + "meta": { + "defaultTitle": "Pasargad Brick Company", + "titleTemplate": "%s | Pasargad Brick Company", + "defaultDescription": "Pasargad Brick Company", + "siteName": "Pasargad Brick Company" + }, + "pages_home_title": "Home", "pages_home_description": "Welcome to the home page", "pages_about_title": "About Us", @@ -90,27 +97,27 @@ "pages_notFound_description": "You can either head back to the Homepage or try a search.", "pages_notFound_button": "Go To Home", - "page_about_metadata_title": "About Us - Brick Factory", + "page_about_metadata_title": "About Us", "page_about_metadata_description": "Learn more about our commitment to producing high-quality bricks using both traditional and modern manufacturing techniques.", - "page_home_metadata_title": "Home - Brick Factory", + "page_home_metadata_title": "Home", "page_home_metadata_description": "Welcome to our official website, where we showcase our expertise, quality, and innovation in brick manufacturing.", - "page_contact_metadata_title": "Contact Us - Brick Factory", + "page_contact_metadata_title": "Contact Us", "page_contact_metadata_description": "Get in touch with us for more information or to place an order. Our team is here to support your building needs.", - "page_products_metadata_title": "Products - Brick Factory", + "page_products_metadata_title": "Products", "page_products_metadata_description": "Explore our variety of traditional and industrial bricks designed to meet the demands of different construction projects.", - "page_blog_metadata_title": "Blog - Brick Factory", + "page_blog_metadata_title": "Blog", "page_blog_metadata_description": "Stay informed with our latest articles, news, and tips related to bricks and building materials.", - "page_projects_metadata_title": "Projects - Brick Factory", + "page_projects_metadata_title": "Projects", "page_projects_metadata_description": "Discover successful projects completed using our high-quality bricks and expert craftsmanship.", - "page_product_categories_metadata_title": "Product Categories - Brick Factory", + "page_product_categories_metadata_title": "Product Categories", "page_product_categories_metadata_description": "Browse through our product categories including Ghazaghi, yellow bricks, facing bricks, and more to find the right solution for your project.", - "page_not_found_metadata_title": "404 Not Found - Brick Factory", + "page_not_found_metadata_title": "404 Not Found", "page_not_found_metadata_description": "The page you are looking for doesn’t exist. You can return to the homepage or search for what you need." } diff --git a/messages/fa.json b/messages/fa.json index 98c6fd4..ddb7c2c 100644 --- a/messages/fa.json +++ b/messages/fa.json @@ -1,4 +1,11 @@ { + "meta": { + "defaultTitle": "آجر نسوز پاسارگاد", + "titleTemplate": "%s | آجر نسوز پاسارگاد", + "defaultDescription": "آجر نسوز پاسارگاد", + "siteName": "آجر نسوز پاسارگاد" + }, + "pages_home_title": "خانه", "pages_home_description": "به صفحه اصلی خوش آمدید", "pages_about_title": "درباره ما", @@ -83,25 +90,25 @@ "pages_notFound_description": "صفحه‌ای که به دنبال آن هستید وجود ندارد یا منتقل شده است. لطفاً آدرس را بررسی کنید یا به صفحه اصلی بازگردید.", "pages_notFound_button": "بازگشت به صفحه اصلی", - "page_about_metadata_title": "درباره ما - کارخانه آجرسازی", + "page_about_metadata_title": "درباره ما", "page_about_metadata_description": "با ما بیشتر آشنا شوید؛ متعهد به تولید آجرهای باکیفیت با بهره‌گیری از فناوری‌های نوین و روش‌های ساخت پیشرفته.", - "page_home_metadata_title": "خانه - کارخانه آجرسازی", + "page_home_metadata_title": "خانه", "page_home_metadata_description": "به وب‌سایت رسمی ما خوش آمدید؛ جایی که کیفیت، تجربه و نوآوری در تولید انواع آجر به نمایش گذاشته می‌شود.", - "page_contact_metadata_title": "تماس با ما - کارخانه آجرسازی", + "page_contact_metadata_title": "تماس با ما", "page_contact_metadata_description": "برای دریافت اطلاعات بیشتر یا ثبت سفارش با ما تماس بگیرید. تیم ما آماده پاسخگویی به شماست.", - "page_products_metadata_title": "محصولات - کارخانه آجرسازی", + "page_products_metadata_title": "محصولات", "page_products_metadata_description": "انواع آجرهای سنتی و صنعتی را در این بخش مشاهده کنید؛ مناسب برای پروژه‌های ساختمانی گوناگون.", - "page_blog_metadata_title": "بلاگ - کارخانه آجرسازی", + "page_blog_metadata_title": "بلاگ", "page_blog_metadata_description": "با مقالات، اخبار و آموزش‌های ما در حوزه آجر و مصالح ساختمانی به‌روز بمانید.", - "page_projects_metadata_title": "پروژه‌ها - کارخانه آجرسازی", + "page_projects_metadata_title": "پروژه‌ها", "page_projects_metadata_description": "نگاهی به پروژه‌های موفق ما که با استفاده از آجرهای با کیفیت اجرا شده‌اند.", - "page_product_categories_metadata_title": "دسته‌بندی محصولات - کارخانه آجرسازی", + "page_product_categories_metadata_title": "دسته‌بندی محصولات", "page_product_categories_metadata_description": "دسته‌بندی کامل آجرها شامل آجر قزاقی، آجر زرد، آجر نما و موارد دیگر را در این بخش بررسی کنید.", "page_not_found_metadata_title": "۴۰۴ - صفحه پیدا نشد", diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index 555b61e..bf15173 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -5,6 +5,31 @@ import { notFound } from 'next/navigation'; import { NextIntlClientProvider } from 'next-intl'; import type { IPageParams } from '@/models/layout.d'; import Head from 'next/head'; +import { getTranslations } from 'next-intl/server'; +import { host } from '@/config'; + +export async function generateMetadata({ params }: { params: IPageParams }) { + const { locale } = await params; + const t = await getTranslations({ locale }); + const url = `${host}/${locale}`; + + return { + title: { + default: t('meta.defaultTitle'), + template: t('meta.titleTemplate'), + }, + description: t('meta.defaultDescription'), + openGraph: { + title: t('meta.defaultTitle'), + description: t('meta.defaultDescription'), + siteName: t('meta.siteName'), + type: 'website', + locale, + url, + }, + authors: [{ name: t('meta.author') }], + }; +} export default async function RootLayout({ children, diff --git a/src/config.ts b/src/config.ts index 53d3b1d..05ef343 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,4 +1,4 @@ export const port = process.env.PORT || 3000; export const host = process.env.VERCEL_PROJECT_PRODUCTION_URL - ? `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}` + ? `${process.env.VERCEL_PROJECT_PRODUCTION_URL}` : `http://localhost:${port}`;