Skip to content

Commit 7350681

Browse files
authored
Merge pull request #2 from leaperone/1-feat-i18n
1 feat i18n
2 parents 3163943 + 9fdbfac commit 7350681

37 files changed

+2007
-68
lines changed

app/(home)/layout.tsx

Lines changed: 0 additions & 7 deletions
This file was deleted.

app/[lang]/(home)/layout.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { ReactNode } from "react";
2+
import { HomeLayout } from "fumadocs-ui/layouts/home";
3+
import { baseOptions } from "@/app/layout.config";
4+
5+
export default async function Layout({ children, params }: { children: ReactNode, params: Promise<{ lang: string }> }) {
6+
const lang = (await params).lang;
7+
return <HomeLayout {...baseOptions(lang)}>{children}</HomeLayout>;
8+
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import Image from 'next/image';
33
import Link from 'next/link';
44
import MultiPostLogo from '@/public/MultiPost-Latest.png';
55

6-
export default function HomePage() {
6+
export default async function HomePage(props: { params: Promise<{ lang: string }> }) {
7+
const lang = (await props.params).lang;
78
return (
89
<main className="flex flex-1 flex-col justify-center items-center text-center p-8">
910
<Image src={MultiPostLogo} alt="MultiPost Logo" width={200} height={200} />
@@ -12,13 +13,13 @@ export default function HomePage() {
1213
MultiPost is a tool that allows you to post to multiple social media platforms from a single interface.
1314
</p>
1415
<div className="flex flex-col sm:flex-row gap-4">
15-
<Button href="/docs/user-guide" icon={<BookCheckIcon />}>
16+
<Button href={`/${lang}/docs/user-guide`} icon={<BookCheckIcon />}>
1617
User Guide
1718
</Button>
1819
<Button href="https://api-docs.multipost.app/" icon={<WebhookIcon />}>
1920
API Reference
2021
</Button>
21-
<Button href="/docs/development" icon={<BugPlayIcon />}>
22+
<Button href={`/${lang}/docs/development`} icon={<BugPlayIcon />}>
2223
Development
2324
</Button>
2425
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { createRelativeLink } from 'fumadocs-ui/mdx';
1010
import { getMDXComponents } from '@/mdx-components';
1111

1212
export default async function Page(props: {
13-
params: Promise<{ slug?: string[] }>;
13+
params: Promise<{ slug?: string[], lang: string }>;
1414
}) {
1515
const params = await props.params;
1616

@@ -19,7 +19,7 @@ export default async function Page(props: {
1919
redirect('https://api-docs.multipost.app/');
2020
}
2121

22-
const page = source.getPage(params.slug);
22+
const page = source.getPage(params.slug, params.lang);
2323
if (!page) notFound();
2424

2525
const MDXContent = page.data.body;

app/[lang]/docs/layout.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { DocsLayout } from "fumadocs-ui/layouts/notebook";
2+
import type { ReactNode } from "react";
3+
import { baseOptions } from "@/app/layout.config";
4+
import { source } from "@/lib/source";
5+
6+
export default async function Layout({
7+
children,
8+
params,
9+
}: {
10+
children: ReactNode;
11+
params: Promise<{ lang: string }>;
12+
}) {
13+
const lang = (await params).lang;
14+
return (
15+
<DocsLayout
16+
{...baseOptions(lang)}
17+
tree={source.pageTree[lang]}
18+
nav={{ ...baseOptions(lang).nav, mode: "auto" }}
19+
>
20+
{children}
21+
</DocsLayout>
22+
);
23+
}

app/layout.tsx renamed to app/[lang]/layout.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { Banner } from 'fumadocs-ui/components/banner';
2-
import './global.css';
2+
import '../global.css';
33
import { RootProvider } from 'fumadocs-ui/provider';
4+
import type { Translations } from 'fumadocs-ui/i18n';
45
import { Inter } from 'next/font/google';
56
import type { ReactNode } from 'react';
7+
import { i18n } from '@/lib/i18n';
68

79
export const metadata = {
810
title: 'MultiPost Documentation',
@@ -13,9 +15,22 @@ const inter = Inter({
1315
subsets: ['latin'],
1416
});
1517

16-
export default function Layout({ children }: { children: ReactNode }) {
18+
// translations
19+
const zh: Partial<Translations> = {
20+
search: '搜索内容',
21+
};
22+
23+
// available languages that will be displayed on UI
24+
const locales = i18n.languages.map(lang => ({
25+
name: lang === 'zh' ? '中文' : 'English',
26+
locale: lang,
27+
}));
28+
29+
export default async function Layout({ children, params }: { children: ReactNode, params: Promise<{ lang: string }> }) {
30+
const lang = (await params).lang;
31+
1732
return (
18-
<html lang="en" className={inter.className} suppressHydrationWarning>
33+
<html lang={lang} className={inter.className} suppressHydrationWarning>
1934
<body className="flex flex-col min-h-screen">
2035
<Banner variant="rainbow" id="try-multiget">
2136
<p>
@@ -25,7 +40,13 @@ export default function Layout({ children }: { children: ReactNode }) {
2540
「MultiGet」
2641
</a>
2742
</Banner>
28-
<RootProvider>{children}</RootProvider>
43+
<RootProvider
44+
i18n={{
45+
locale: lang,
46+
locales,
47+
translations: { zh }[lang],
48+
}}
49+
>{children}</RootProvider>
2950
</body>
3051
</html>
3152
);

app/docs/layout.tsx

Lines changed: 0 additions & 12 deletions
This file was deleted.

app/layout.config.tsx

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
2-
import { ActivityIcon, ChromeIcon, HomeIcon, LayoutDashboardIcon, MailIcon, PuzzleIcon } from 'lucide-react';
3-
import Image from 'next/image';
1+
import type { BaseLayoutProps } from "fumadocs-ui/layouts/shared";
2+
import {
3+
ActivityIcon,
4+
ChromeIcon,
5+
HomeIcon,
6+
LayoutDashboardIcon,
7+
MailIcon,
8+
PuzzleIcon,
9+
} from "lucide-react";
10+
import Image from "next/image";
11+
import { i18n } from "@/lib/i18n";
12+
import Link from "next/link";
413

514
/**
615
* Shared layout configurations
@@ -9,68 +18,70 @@ import Image from 'next/image';
918
* Home Layout: app/(home)/layout.tsx
1019
* Docs Layout: app/docs/layout.tsx
1120
*/
12-
export const baseOptions: BaseLayoutProps = {
13-
githubUrl: 'https://github.com/leaperone/MultiPost-Extension',
21+
export const baseOptions = (locale: string): BaseLayoutProps => ({
22+
i18n,
23+
githubUrl: "https://github.com/leaperone/MultiPost-Extension",
1424
nav: {
1525
title: (
16-
<>
17-
<Image
18-
width={24}
19-
height={24}
20-
src="/favicon.ico"
21-
alt="Logo"
22-
className="rounded-full"
23-
/>
24-
MultiPost
25-
</>
26+
<Link href={`/${locale}/`}>
27+
<div className="flex items-center gap-2">
28+
<Image
29+
width={24}
30+
height={24}
31+
src="/favicon.ico"
32+
alt="Logo"
33+
className="rounded-full"
34+
/>
35+
MultiPost
36+
</div>
37+
</Link>
2638
),
27-
transparentMode: 'top',
39+
transparentMode: "top",
2840
},
2941
links: [
30-
3142
{
32-
type: 'icon',
33-
label: 'Home Link',
34-
text: 'Home',
43+
type: "icon",
44+
label: "Home Link",
45+
text: "Home",
3546
icon: <HomeIcon />,
36-
url: 'https://multipost.app',
47+
url: "https://multipost.app",
3748
},
3849
{
39-
type: 'icon',
40-
label: 'Dashboard Link',
41-
text: 'Dashboard',
50+
type: "icon",
51+
label: "Dashboard Link",
52+
text: "Dashboard",
4253
icon: <LayoutDashboardIcon />,
43-
url: 'https://multipost.app/dashboard',
54+
url: "https://multipost.app/dashboard",
4455
},
4556
{
46-
type: 'icon',
47-
label: 'Contact Us Link',
48-
text: 'Contact Us',
57+
type: "icon",
58+
label: "Contact Us Link",
59+
text: "Contact Us",
4960
icon: <MailIcon />,
50-
url: '/docs/user-guide/contact-us',
61+
url: `/${locale}/docs/user-guide/contact-us`,
5162
},
5263
{
53-
type: 'icon',
54-
label: 'MultiPost Status',
55-
text: 'Status',
64+
type: "icon",
65+
label: "MultiPost Status",
66+
text: "Status",
5667
icon: <ActivityIcon />,
57-
url: 'https://monitor.leaper.one',
68+
url: "https://monitor.leaper.one",
5869
},
5970
{
60-
type: 'menu',
61-
text: 'Extensions',
71+
type: "menu",
72+
text: "Extensions",
6273
items: [
6374
{
6475
icon: <ChromeIcon />,
65-
text: 'Install MultiPost',
66-
url: 'https://multipost.app/extension',
76+
text: "Install MultiPost",
77+
url: "https://multipost.app/extension",
6778
},
6879
{
6980
icon: <PuzzleIcon />,
70-
text: 'Install MultiGet',
71-
url: 'https://chromewebstore.google.com/detail/multiget/bhggbcoodmbomiaffjbpkafajbgcchgi',
81+
text: "Install MultiGet",
82+
url: "https://chromewebstore.google.com/detail/multiget/bhggbcoodmbomiaffjbpkafajbgcchgi",
7283
},
7384
],
7485
},
7586
],
76-
};
87+
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: Overview
3+
---
4+
5+
<Callout title="API Documentation">
6+
Please visit <a href="https://api-docs.multipost.app/" target="_blank">API Documentation</a> for the latest API interface information.
7+
</Callout>
8+
9+
MultiPost provides rich API interfaces, allowing developers to remotely call our extension interfaces, enabling semi-automatic and fully automatic content publishing to multiple platforms.
10+
11+
Currently, we provide the following API interfaces:
12+
13+
## Extension API
14+
15+
In your Web App, call MultiPost Extension interfaces to implement publishing, get account information, get platform information and other functions.
16+
17+
## Restful API (Beta, Only for Version above 1.1.0)
18+
19+
We provide Restful API in multipost.app, allowing developers to remotely call our extension interfaces to implement extension information retrieval, publishing task creation and other functions. Currently supports remote calling, scheduled publishing and other functions.
20+
21+
## Scraper API
22+
23+
We provide Scraper API in multipost.app, allowing developers to remotely call our extension interfaces to implement content scraping, searching and other functions.
24+
25+
## Social Media API
26+
27+
We provide Social Media API in multipost.app, allowing developers to remotely call our extension interfaces to implement social media content scraping, searching and other functions.
28+
29+
## What is Next?
30+
31+
<Cards>
32+
<Card title="Learn more about Extension API" href="https://api-docs.multipost.app/" />
33+
<Card title="Learn more about Restful API" href="https://api-docs.multipost.app/" />
34+
<Card title="MultiPost" href="https://multipost.app" />
35+
<Card title="User Guide" href="/docs/user-guide" />
36+
</Cards>

0 commit comments

Comments
 (0)