40 lines
851 B
TypeScript
40 lines
851 B
TypeScript
import { type Locale } from '@/i18n/config';
|
|
|
|
export function WebPageJsonLd({
|
|
title,
|
|
description,
|
|
url,
|
|
locale,
|
|
}: {
|
|
title: string;
|
|
description: string;
|
|
url: string;
|
|
locale: Locale;
|
|
}) {
|
|
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://damjan-savic.com';
|
|
|
|
const schema = {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'WebPage',
|
|
name: title,
|
|
description: description,
|
|
url: url.startsWith('http') ? url : `${baseUrl}${url}`,
|
|
inLanguage: locale === 'de' ? 'de-DE' : locale === 'sr' ? 'sr-RS' : 'en-US',
|
|
isPartOf: {
|
|
'@type': 'WebSite',
|
|
name: 'Damjan Savić',
|
|
url: baseUrl,
|
|
},
|
|
author: {
|
|
'@id': `${baseUrl}/#person`,
|
|
},
|
|
};
|
|
|
|
return (
|
|
<script
|
|
type="application/ld+json"
|
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(schema) }}
|
|
/>
|
|
);
|
|
}
|