funktechnik-schubert-website/app/seo.ts

91 lines
2.6 KiB
TypeScript

import type { Metadata } from "next";
import type { SeoContent } from "@/lib/content/types";
const siteName = "Funktechnik Schubert";
const defaultTitle = "Funktechnik Schubert | Funkgeräte-Service & Messtechnik";
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL ?? "http://127.0.0.1:3010";
const keywords = [
"Funktechnik Schubert",
"Funkgeräte Reparatur",
"CB Funk Service",
"Amateurfunk Service",
"Funkgeräte Abgleich",
"Funkgeräte Diagnose",
"Messtechnik",
"Funktechnik Service",
"Kommunikationstechnik",
"Service Manual",
"Schaltplan",
"Funkwerkstatt",
"Reparaturannahme",
];
export function createMetadata(title: string, description: string, path = "/"): Metadata {
const url = new URL(path, siteUrl).toString();
const fullTitle = title === siteName ? title : `${title} | ${siteName}`;
return {
metadataBase: new URL(siteUrl),
title: title === siteName ? { default: defaultTitle, template: `%s | ${siteName}` } : fullTitle,
applicationName: siteName,
description,
keywords,
icons: {
icon: [
{ url: "/favicon.ico", sizes: "any" },
{ url: "/favicon-16x16.png", sizes: "16x16", type: "image/png" },
{ url: "/favicon-32x32.png", sizes: "32x32", type: "image/png" },
],
apple: [{ url: "/apple-touch-icon.png", sizes: "180x180", type: "image/png" }],
},
alternates: {
canonical: url,
},
openGraph: {
type: "website",
locale: "de_DE",
url,
siteName,
title: fullTitle,
description,
images: [
{
url: "/funktechnik_schubert_logo.jpg",
width: 1672,
height: 941,
alt: siteName,
},
],
},
};
}
export function createContentMetadata(seo: SeoContent): Metadata {
const path = seo.canonicalUrl || "/";
const url = new URL(path, siteUrl).toString();
const title = seo.metaTitle || siteName;
const description = seo.metaDescription || defaultTitle;
return {
...createMetadata(title, description, path),
keywords: seo.keywords ? seo.keywords.split(",").map((keyword) => keyword.trim()).filter(Boolean) : keywords,
openGraph: {
type: "website",
locale: "de_DE",
url,
siteName,
title: seo.openGraphTitle || title,
description: seo.openGraphDescription || description,
images: [
{
url: seo.socialImage || "/funktechnik_schubert_logo.jpg",
width: 1200,
height: 630,
alt: seo.openGraphTitle || title,
},
],
},
};
}
export { defaultTitle, siteName, siteUrl };