|
1 | | -'use client'; |
| 1 | +import Ability from '@/components/home/Ability'; |
| 2 | +import CTA from '@/components/home/CTA'; |
| 3 | +import FAQ from '@/components/home/FAQ'; |
| 4 | +import Feature from '@/components/home/Feature'; |
| 5 | +import Hero from '@/components/home/Hero'; |
| 6 | +import VideoPlayer from '@/components/home/Video'; |
| 7 | +import Header from '@/components/header/Header'; |
| 8 | +import JsonLd from '@/components/JsonLd'; |
| 9 | +import { defaultLocale, getDictionary } from '@/lib/i18n'; |
| 10 | +import { getAlternates } from '@/lib/seo'; |
| 11 | +import { getGitHubStars } from '@/lib/utils'; |
| 12 | +import { siteConfig, siteConfigZh, siteConfigJa } from '@/config/site'; |
| 13 | +import { Metadata } from 'next'; |
2 | 14 |
|
3 | | -import { useEffect } from 'react'; |
4 | | -import { defaultLocale, localeNames } from '@/lib/i18n'; |
| 15 | +const configMap: Record<string, typeof siteConfig> = { en: siteConfig, zh: siteConfigZh, ja: siteConfigJa }; |
| 16 | +const rootConfig = configMap[defaultLocale] || siteConfig; |
5 | 17 |
|
6 | | -export default function RootPage() { |
7 | | - useEffect(() => { |
8 | | - const storedLang = localStorage.getItem('preferredLang'); |
9 | | - const lang = |
10 | | - storedLang && Object.keys(localeNames).includes(storedLang) |
11 | | - ? storedLang |
12 | | - : defaultLocale; |
13 | | - window.location.replace(`/${lang}`); |
14 | | - }, []); |
| 18 | +export const metadata: Metadata = { |
| 19 | + title: rootConfig.title, |
| 20 | + description: rootConfig.description, |
| 21 | + keywords: rootConfig.keywords, |
| 22 | + alternates: getAlternates(defaultLocale, '') |
| 23 | +}; |
15 | 24 |
|
16 | | - return null; |
| 25 | +export default async function RootPage() { |
| 26 | + const dict = await getDictionary(defaultLocale); |
| 27 | + const stars = await getGitHubStars(); |
| 28 | + |
| 29 | + return ( |
| 30 | + <> |
| 31 | + <JsonLd lang={defaultLocale} /> |
| 32 | + <Header dict={dict} CTALocale={dict.CTAButton} /> |
| 33 | + <main className="flex flex-col items-center mt-12 sm:mt-14 lg:mt-20"> |
| 34 | + <div className="mx-4 sm:mx-6 md:mx-12 xl:mx-[60px] 2xl:max-w-7xl 2xl:mx-auto flex flex-col items-center margin-top-40"> |
| 35 | + <Hero locale={dict.Hero} CTALocale={dict.CTAButton} stars={stars} /> |
| 36 | + <VideoPlayer locale={dict.Video} dict={dict} /> |
| 37 | + <Ability id="Ability" locale={dict.Ability} langName={defaultLocale} /> |
| 38 | + <Feature id="Features" locale={dict.Feature} langName={defaultLocale} /> |
| 39 | + <FAQ id="FAQ" locale={dict.FAQ} langName={defaultLocale} /> |
| 40 | + <CTA locale={dict.CTA} CTALocale={dict.CTAButton} stars={stars} /> |
| 41 | + </div> |
| 42 | + </main> |
| 43 | + </> |
| 44 | + ); |
17 | 45 | } |
0 commit comments