From a2c9b7fd088bb664a3ca8fcb5d1c4760a838e7d9 Mon Sep 17 00:00:00 2001 From: Rafi Arrafif Date: Tue, 5 Aug 2025 13:17:04 +0700 Subject: [PATCH] :triangular_flag_on_post: create HTML meta tag helper --- app/(auth)/log-in/page.tsx | 7 +++++++ app/(auth)/sign-up/page.tsx | 7 +++++++ shared/config/meta.ts | 29 +++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 shared/config/meta.ts diff --git a/app/(auth)/log-in/page.tsx b/app/(auth)/log-in/page.tsx index cda3971..bdb90a5 100644 --- a/app/(auth)/log-in/page.tsx +++ b/app/(auth)/log-in/page.tsx @@ -1,6 +1,13 @@ +import { buildMeta } from "@/shared/config/meta"; import LoginCard from "@/widgets/authentication/login/LoginCard"; import React from "react"; +export const generateMetadata = () => { + return buildMeta({ + title: "Log in", + }); +}; + const page = () => { return (
diff --git a/app/(auth)/sign-up/page.tsx b/app/(auth)/sign-up/page.tsx index 28f22be..57a7c08 100644 --- a/app/(auth)/sign-up/page.tsx +++ b/app/(auth)/sign-up/page.tsx @@ -1,6 +1,13 @@ +import { buildMeta } from "@/shared/config/meta"; import SignupCard from "@/widgets/authentication/signup/SignupCard"; import React from "react"; +export const generateMetadata = () => { + return buildMeta({ + title: "Sign in", + }); +}; + const page = () => { return (
diff --git a/shared/config/meta.ts b/shared/config/meta.ts new file mode 100644 index 0000000..c75e69d --- /dev/null +++ b/shared/config/meta.ts @@ -0,0 +1,29 @@ +type BuildMeta = { + title?: string; + description?: string; + image?: string; +}; + +const appName = process.env.APP_NAME; +export const defaultMeta = { + title: appName || "Unknown App", + description: "Interactive community", +}; + +export const buildMeta = ({ title, description, image }: BuildMeta) => { + return { + title: title ? `${title} - ${appName}` : defaultMeta.title, + description: description || defaultMeta.description, + openGraph: { + title, + description, + images: image ? [image] : ["/default-og.png"], + }, + twitter: { + card: "summary_large_image", + title, + description, + images: image ? [image] : ["/default-og.png"], + }, + }; +};