diff --git a/README.md b/README.md index 44c5e5fe1..f10080b44 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ This open-source repo contains internationalization libraries for React framewor ## Add the `` component and see translations as you code: -![Demo](./apps/docs/public/live_translations.gif) +![Demo](./apps/docs/public/demo.gif) ## Features diff --git a/apps/docs/app/[locale]/docs/[[...slug]]/page.tsx b/apps/docs/app/[locale]/docs/[[...slug]]/page.tsx index 5297cb937..ae185cf08 100644 --- a/apps/docs/app/[locale]/docs/[[...slug]]/page.tsx +++ b/apps/docs/app/[locale]/docs/[[...slug]]/page.tsx @@ -32,6 +32,9 @@ import SupportedLocales from '@/components/SupportedLocales'; import { InlineTOC } from 'fumadocs-ui/components/inline-toc'; import { Rate } from '@/components/rate'; import { Metadata } from 'next'; +import { getLocale } from 'gt-next/server'; +import { Mermaid } from '@/components/mdx/mermaid'; +import Video from '@/components/Video'; const customMdxComponents = { a: (props: React.ComponentProps<'a'>) => ( @@ -46,11 +49,15 @@ const customMdxComponents = { LogoCardContent, AllLogoCards, SupportedLocales, + Mermaid, + Video, }; export default async function Page(props: { params: Promise<{ slug?: string[]; locale: string }>; }) { - const { slug, locale } = await props.params; + const { slug } = await props.params; + const locale = await getLocale(); + const page = source.getPage(slug, locale); if (!page) notFound(); diff --git a/apps/docs/app/[locale]/layout.tsx b/apps/docs/app/[locale]/layout.tsx index 5de3e2dd0..bc0029edd 100644 --- a/apps/docs/app/[locale]/layout.tsx +++ b/apps/docs/app/[locale]/layout.tsx @@ -6,23 +6,26 @@ import { DocsLayout } from 'fumadocs-ui/layouts/notebook'; import type { ReactNode } from 'react'; import { baseOptions } from '@/app/[locale]/layout.config'; import { source } from '@/lib/source'; -import { GTProvider } from 'gt-next'; +import { GTProvider, T } from 'gt-next'; import { getLocaleProperties } from 'generaltranslation'; import { SiGithub } from '@icons-pack/react-simple-icons'; import { PostHogProvider } from '@/components/analytics/PostHogProvider'; import AnalyticsBanner from '@/components/analytics/AnalyticsBanner'; import SearchDialog from '@/components/SearchDialog'; import PrefetchSearchIndex from '@/components/PrefetchSearchIndex'; +import { getGT, getLocale, getLocales } from 'gt-next/server'; const inter = Inter({ subsets: ['latin'], }); -export function generateMetadata(): Metadata { +export async function generateMetadata(): Promise { + const gt = await getGT(); return { - title: 'Docs — General Translation', - description: - 'Documentation for the General Translation internationalization platform', + title: gt('Docs — General Translation'), + description: gt( + 'Documentation for the General Translation internationalization platform' + ), icons: { icon: [ { @@ -38,15 +41,15 @@ export function generateMetadata(): Metadata { ], }, keywords: [ - 'translation', - 'localization', - 'l10n', - 'i18n', - 'internationalization', - 'automate', - 'next.js', - 'nextjs', - 'react', + gt('translation'), + gt('localization'), + gt('internationalization'), + gt('l10n', { context: 'localization' }), + gt('i18n', { context: 'internationalization' }), + gt('automate'), + gt('next.js'), + gt('nextjs'), + gt('react'), ], }; } @@ -55,16 +58,10 @@ function capitalize(str: string) { return str.charAt(0).toUpperCase() + str.slice(1); } -export default async function Layout({ - children, - params, -}: { - children: ReactNode; - params: Promise<{ locale: string }>; -}) { - const { locale } = await params; +export default async function Layout({ children }: { children: ReactNode }) { + const locale = await getLocale(); const options = await baseOptions(locale); - const locales = ['en', 'zh', 'de', 'fr', 'es', 'ja'].map((locale) => ({ + const locales = getLocales().map((locale) => ({ name: capitalize(getLocaleProperties(locale, locale).languageName), locale: locale, })); @@ -118,7 +115,7 @@ export default async function Layout({ }, }, banner: ( - <> + - + ), }} tree={source.pageTree[locale]} diff --git a/apps/docs/components/Video.tsx b/apps/docs/components/Video.tsx index c71966fc3..f4f3d4eeb 100644 --- a/apps/docs/components/Video.tsx +++ b/apps/docs/components/Video.tsx @@ -1,5 +1,3 @@ -import { BASE_URL } from '@/lib/constants'; - export default function Video({ src }: { src: string }) { - return