Files
kaman-cable/src/lib/seo.ts
T

49 lines
1.1 KiB
TypeScript

import type { Metadata } from "next";
import { defaultLocale, localeOg, type Locale } from "@/i18n/config";
import { getMessages } from "@/i18n/index";
import { websiteDomain } from "@/lib/config";
export const siteUrl = `https://${websiteDomain}`;
export function pageMetadata({
title,
description,
path = "/",
image,
absolute = false,
locale = defaultLocale,
}: {
title: string;
description: string;
path?: string;
image?: string | null;
absolute?: boolean;
locale?: Locale;
}): Metadata {
const url = `${siteUrl}${path.startsWith("/") ? path : `/${path}`}`;
const ogImage = image || `${siteUrl}/images/slider/bg1.jpg`;
const t = getMessages(locale);
return {
title: absolute ? { absolute: title } : title,
description,
alternates: { canonical: url },
openGraph: {
type: path === "/" ? "website" : "article",
locale: localeOg[locale],
url,
siteName: t.brand.shortName,
title,
description,
images: [{ url: ogImage, alt: title }],
},
twitter: {
card: "summary_large_image",
title,
description,
images: [ogImage],
},
};
}