fix: missing metadata

This commit is contained in:
Dariusz Niemczyk 2025-02-09 03:07:23 +01:00
parent ff033eb1a1
commit a9c98ee778
No known key found for this signature in database
4 changed files with 71 additions and 9 deletions

View file

@ -6,10 +6,68 @@ import { getLocale, Lang } from "@/i18n/locales";
import Head from 'next/head';
import { ThemeProvider } from "@/components/providers";
import { translations } from "@/i18n/translations";
import { Oxanium } from "next/font/google";
import { headers } from "next/headers";
const oxanium = Oxanium({ subsets: ["latin-ext"] })
import type { Metadata } from 'next';
type Props = {
params: Promise<{ locale: Lang }>
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}
export async function generateMetadata(
{ params }: Props,
): Promise<Metadata> {
// read route params
const locale = (await params).locale
const currentLang = getLocale(locale);
const t = translations[currentLang];
return {
title: "CebulaCamp",
description: "An amazing gathering of hackers and open source enthusiasts.",
icons: {
icon: [
{ url: '/favicon-96x96.png', type: 'image/png' },
{ url: '/favicon.svg', type: 'image/svg+xml' },
{ url: '/favicon.ico', type: 'image/x-icon' }
],
apple: '/apple-touch-icon.png',
},
manifest: '/site.webmanifest',
other: {
'apple-mobile-web-app-title': t.siteTitle,
},
openGraph: {
title: t.siteTitle,
description: 'An amazing gathering of hackers and open source enthusiasts.',
url: 'https://cebula.camp',
images: [
{
url: 'https://cebula.camp/web-app-manifest-512x512.png',
width: 512,
height: 512,
alt: t.siteTitle,
},
],
siteName: t.siteTitle,
type: 'website',
},
twitter: {
card: 'summary_large_image',
title: 'CebulaCamp',
description: 'An amazing gathering of hackers and open source enthusiasts.',
images: ['https://cebula.camp/web-app-manifest-512x512.png'],
},
};
}
export default async function RootLayout({
children,
@ -32,15 +90,19 @@ export default async function RootLayout({
const currentLang = getLocale(locale);
const defaultTheme = isDarkOrLight ? preferedTheme : "dark";
const t = translations[currentLang];
return (
<html lang={currentLang} className={`${oxanium.className} ${defaultTheme}`}>
<Head>
<title>{t.siteTitle}</title>
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<meta name="apple-mobile-web-app-title" content="CebulaCamp" />
<link rel="manifest" href="/site.webmanifest" />
</Head>
<body className="bg-background text:foreground antialiased">
<ThemeProvider>

View file

@ -70,10 +70,7 @@ export function Nav({
<div className="flex gap-4">
<LanguageSelector />
<a href="#" className="text-xl font-bold tracking-tighter hover:text-primary transition-colors">
<h1>{t.siteTitle}</h1>
<h1>{t.nav.title}</h1>
</a>
</div>
<div className="flex items-center">

View file

@ -8,10 +8,11 @@ import { useParams } from "next/navigation";
export const LanguageSelector = () => {
const params = useParams<{ locale: Lang }>();
const lang = params?.locale || 'pl';
const hash = window?.location?.hash || '';
const hash = globalThis?.window?.location?.hash || '';
if (lang === 'pl') return (<>
<Link className="pt-1" href={`/en${hash}`}>🇬🇧</Link></>);
<Link suppressHydrationWarning className="pt-1" href={`/en${hash}`}>🇬🇧</Link></>);
if (lang === 'en') return (<>
<Link className="pt-1" href={`/pl${hash}`}>🇵🇱</Link></>);
<Link suppressHydrationWarning className="pt-1" href={`/pl${hash}`}>🇵🇱</Link></>);
};

View file

@ -4,8 +4,9 @@ const common = {
};
const pl = {
siteTitle: "CEBULACAMP",
siteTitle: "CebulaCamp",
nav: {
title: "CEBULACAMP",
hero: "Cebula",
about: "O nas",
when: "Kiedy",
@ -65,8 +66,9 @@ const pl = {
};
const en = {
siteTitle: "CEBULACAMP",
siteTitle: "CebulaCamp 2025",
nav: {
title: "CEBULACAMP",
hero: "Onion",
about: "About us",
when: "When",