Skip to content

Commit e84b62e

Browse files
committed
Fixed root metadata generator
1 parent 915bf9e commit e84b62e

2 files changed

Lines changed: 39 additions & 23 deletions

File tree

src/app/(root)/layout.tsx

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11
import type { Metadata } from "next";
22
import "../globals.css";
3-
import { getTranslations } from "next-intl/server";
3+
import { getTranslations, setRequestLocale } from "next-intl/server";
44

5-
const locale = 'zh-tw';
6-
const t = await getTranslations({ locale, namespace: 'Metadata' });
5+
export async function generateMetadata({}: {params: Promise<{locale: string}>}){
6+
const locale = 'zh-tw';
7+
const t = await getTranslations({ locale, namespace: 'Metadata' });
78

8-
export const metadata: Metadata = {
9-
icons: [{ rel: "icon", url: "/logo/twds_circle.svg" }],
10-
title: t('title'),
11-
description: t('description'),
12-
keywords: "networking, security, open source, sustainability, technology, startups, future, Taiwan, sustainability, education, cybersecurity",
13-
authors: [{ name: "Taiwan Digital Streaming Co." }],
14-
openGraph: {
9+
return {
10+
icons: [{ rel: "icon", url: "/logo/twds_circle.svg" }],
1511
title: t('title'),
1612
description: t('description'),
17-
type: "website",
18-
locale: locale === 'zh-tw' ? 'zh_TW' : 'en_US',
19-
url: "https://www.twds.com.tw/",
20-
images: "https://www.twds.com.tw/img/og.png",
21-
},
22-
twitter: {
23-
card: "summary_large_image",
24-
title: t('title'),
25-
description: t('description'),
26-
},
27-
};
13+
keywords: "networking, security, open source, sustainability, technology, startups, future, Taiwan, sustainability, education, cybersecurity",
14+
authors: [{ name: "Taiwan Digital Streaming Co." }],
15+
openGraph: {
16+
title: t('title'),
17+
description: t('description'),
18+
type: "website",
19+
locale: locale === 'zh-tw' ? 'zh_TW' : 'en_US',
20+
url: "https://www.twds.com.tw/",
21+
images: "https://www.twds.com.tw/img/og.png",
22+
},
23+
twitter: {
24+
card: "summary_large_image",
25+
title: t('title'),
26+
description: t('description'),
27+
},
28+
};
29+
}
2830

2931
export default function RootLayout({
3032
children,
3133
}: Readonly<{
3234
children: React.ReactNode;
3335
}>) {
36+
setRequestLocale('zh-tw');
3437
return (
3538
<html lang="zh-TW">
3639
<body>

src/app/(root)/page.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
import { redirect } from 'next/navigation';
1+
'use client'
2+
3+
import { useEffect } from 'react';
24
import { routing } from '@/i18n/routing';
35

46
export default function RootPage() {
5-
redirect(`/${routing.defaultLocale}`);
7+
useEffect(() => {
8+
window.location.href = `/${routing.defaultLocale}`;
9+
}, []);
10+
11+
return (
12+
<div className="min-h-screen flex items-center justify-center">
13+
<div className="text-center">
14+
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-green-500 mx-auto mb-4"></div>
15+
<p className="text-gray-600">Redirecting...</p>
16+
</div>
17+
</div>
18+
);
619
}

0 commit comments

Comments
 (0)