aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/packages/docs/app/lib
diff options
context:
space:
mode:
author简律纯 <i@jyunko.cn>2026-02-10 13:28:23 +0800
committerGitHub <noreply@github.com>2026-02-10 13:28:23 +0800
commit21ec63eaaf2ab1cb088f1c1787200a91cce460a5 (patch)
treed3ffcbd1a53b4567c1ba5995a49ecf656fb3c596 /packages/docs/app/lib
parent3bc1e77f3922d5bdb824d1249971738a8d175f41 (diff)
downloadDropOut-21ec63eaaf2ab1cb088f1c1787200a91cce460a5.tar.gz
DropOut-21ec63eaaf2ab1cb088f1c1787200a91cce460a5.zip
chore: sync with main [skip ci] (#91)
Co-authored-by: NtskwK <natsukawa247@outlook.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Diffstat (limited to 'packages/docs/app/lib')
-rw-r--r--packages/docs/app/lib/i18n.ts8
-rw-r--r--packages/docs/app/lib/layout.shared.tsx24
-rw-r--r--packages/docs/app/lib/source.ts12
3 files changed, 44 insertions, 0 deletions
diff --git a/packages/docs/app/lib/i18n.ts b/packages/docs/app/lib/i18n.ts
new file mode 100644
index 0000000..a9f18b1
--- /dev/null
+++ b/packages/docs/app/lib/i18n.ts
@@ -0,0 +1,8 @@
+import { defineI18n } from 'fumadocs-core/i18n';
+
+export const i18n = defineI18n({
+ defaultLanguage: 'zh',
+ languages: ['zh', 'en'],
+ hideLocale: 'default-locale',
+ parser: 'dir', // 使用目录结构 (content/zh/*, content/en/*)
+});
diff --git a/packages/docs/app/lib/layout.shared.tsx b/packages/docs/app/lib/layout.shared.tsx
new file mode 100644
index 0000000..6e90ba0
--- /dev/null
+++ b/packages/docs/app/lib/layout.shared.tsx
@@ -0,0 +1,24 @@
+import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
+import { i18n } from './i18n';
+
+export function baseOptions(locale: string): BaseLayoutProps {
+ // 默认语言(zh)不显示前缀,其他语言显示前缀
+ const isDefaultLocale = locale === i18n.defaultLanguage;
+ const localePrefix = isDefaultLocale ? '' : `/${locale}`;
+
+ return {
+ i18n,
+ nav: {
+ title: 'DropOut',
+ url: localePrefix || '/',
+ },
+ githubUrl: 'https://github.com/HydroRoll-Team/DropOut',
+ links: [
+ {
+ type: 'main',
+ text: locale === 'zh' ? '文档' : 'Documentation',
+ url: `${localePrefix}/docs`,
+ },
+ ],
+ };
+}
diff --git a/packages/docs/app/lib/source.ts b/packages/docs/app/lib/source.ts
new file mode 100644
index 0000000..bce9bf9
--- /dev/null
+++ b/packages/docs/app/lib/source.ts
@@ -0,0 +1,12 @@
+import { loader } from 'fumadocs-core/source';
+import { docs } from 'fumadocs-mdx:collections/server';
+import { i18n } from './i18n';
+
+export const source = loader({
+ source: docs.toFumadocsSource(),
+ baseUrl: '/docs',
+ i18n,
+ // hideLocale: 'default-locale' 会自动生成正确的 URL:
+ // - 默认语言 (zh): /docs/getting-started
+ // - 其他语言 (en): /en/docs/getting-started
+});