diff --git a/src/app/(frontend)/[locale]/[[...slug]]/page.tsx b/src/app/(frontend)/[locale]/[[...slug]]/page.tsx index ebec83b..d05bcf9 100644 --- a/src/app/(frontend)/[locale]/[[...slug]]/page.tsx +++ b/src/app/(frontend)/[locale]/[[...slug]]/page.tsx @@ -13,6 +13,13 @@ type FAQFullBlock = Extract[0], { blockType: 'faqFul import type { Metadata } from 'next' +import { createPageMetadata } from '@intecion/ipal-kit' + +const pageMetadata = createPageMetadata({ + config: i18n, + baseUrl: process.env.NEXT_PUBLIC_SERVER_URL || 'https://www.jkedzierski.de' +}) + export async function generateMetadata( props: { params: Promise<{ locale: string; slug?: string[] }> } ): Promise { @@ -20,46 +27,7 @@ export async function generateMetadata( const { locale, slug } = params const payload = await getPayload({ config: configPromise }) - const route = await resolveRoute({ payload, locale, segments: slug || [] }) - if (!route) { - return {} - } - - const doc = await payload.findByID({ - collection: ('collection' in route ? route.collection : 'pages') as 'pages', - id: route.doc.id as string, - locale: locale as 'all' | 'pl' | 'de' | 'en', - }) - - // Retrieve meta object injected by @payloadcms/plugin-seo - const meta = (doc as any).meta - - const title = meta?.title || doc.title - const description = meta?.description || '' - - let imageUrl = '' - if (meta?.image && typeof meta.image === 'object' && meta.image.url) { - imageUrl = meta.image.url - } else if (meta?.image && typeof meta.image === 'string') { - // If it's just an ID, we might not have the full URL without a separate fetch, - // but usually Payload plugin-seo populates the image relationship. - } - - return { - title, - description, - openGraph: { - title, - description, - ...(imageUrl && { images: [{ url: imageUrl }] }), - }, - twitter: { - card: 'summary_large_image', - title, - description, - ...(imageUrl && { images: [imageUrl] }), - }, - } + return pageMetadata({ payload, locale, slug }) } export default async function Page(props: { diff --git a/src/app/(frontend)/[locale]/layout.tsx b/src/app/(frontend)/[locale]/layout.tsx index 4cbc38d..49ef114 100644 --- a/src/app/(frontend)/[locale]/layout.tsx +++ b/src/app/(frontend)/[locale]/layout.tsx @@ -20,10 +20,7 @@ const fraunces = Fraunces({ variable: '--font-heading', }) -export const metadata = { - title: 'Finanz- & Lohnbuchhaltung Dipl.-Ing. Janusz Kędzierski', - description: 'Profesjonalne doradztwo podatkowe.', -} + export default async function RootLayout(props: { children: React.ReactNode, @@ -61,12 +58,12 @@ export default async function RootLayout(props: { const schemaOrg = { "@context": "https://schema.org", "@type": "AccountingService", - "name": "Finanz- & Lohnbuchhaltung Dipl.-Ing. Janusz Kędzierski", + "name": siteData?.siteName || "Finanz- & Lohnbuchhaltung Dipl.-Ing. Janusz Kędzierski", "telephone": companyData?.phone || '', "email": companyData?.email || '', "address": companyData?.address || '', "openingHours": companyData?.hours || '', - "url": "https://www.jkedzierski.de" + "url": process.env.NEXT_PUBLIC_SERVER_URL || "https://www.jkedzierski.de" }; return ( diff --git a/src/app/robots.ts b/src/app/robots.ts new file mode 100644 index 0000000..8a52da6 --- /dev/null +++ b/src/app/robots.ts @@ -0,0 +1,5 @@ +import { buildRobots } from '@intecion/ipal-kit' + +export default function robots() { + return buildRobots({ baseUrl: process.env.NEXT_PUBLIC_SERVER_URL || '' }) +} diff --git a/src/app/sitemap.ts b/src/app/sitemap.ts new file mode 100644 index 0000000..ae0529e --- /dev/null +++ b/src/app/sitemap.ts @@ -0,0 +1,13 @@ +import { getPayload } from 'payload' +import configPromise from '@payload-config' +import { buildSitemapEntries } from '@intecion/ipal-kit' +import { i18n } from '../i18n.config' + +export default async function sitemap() { + const payload = await getPayload({ config: configPromise }) + return buildSitemapEntries({ + payload, + config: i18n, + baseUrl: process.env.NEXT_PUBLIC_SERVER_URL || '', + }) +}