This commit is contained in:
Your Name committed 2026-06-20 18:57:24 -04:00
1 parent f7aa4d099f
commit ab3e53c4da
33 files changed
+290 -69

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
import { Metadata } from 'next';
import { SUPPORTED_LOCALES } from './locales';
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3000';
type SeoMetadataProps = {
title: string;
description: string;
path: string; // e.g. '/shop', '/category/1', or ''
lang: string;
openGraph?: Metadata['openGraph'];
};
export function generateSeoMetadata({
title,
description,
path,
lang,
openGraph,
}: SeoMetadataProps): Metadata {
const cleanPath = path.startsWith('/') ? path : `/${path}`;
const pathPart = cleanPath === '/' ? '' : cleanPath;
const languages: Record<string, string> = {};
SUPPORTED_LOCALES.forEach((locale) => {
languages[locale] = `${baseUrl}/${locale}${pathPart}`;
});
return {
title,
description,
alternates: {
canonical: `${baseUrl}/${lang}${pathPart}`,
languages,
},
openGraph,
};
}