Add documents site (#1767)

* feat: add docs site

- Implemented dynamic routing for MDX documentation pages with language support.
- Created layout components for documentation with a header and footer.
- Added metadata for various documentation sections in English and Chinese.
- Developed initial content for the DeerFlow App and Harness documentation.
- Introduced i18n hooks and translations for English and Chinese languages.
- Enhanced header component to include navigation links for documentation and blog.
- Established a structure for tutorials and reference materials.
- Created a new translations file to manage locale-specific strings.

* feat: enhance documentation structure and content for application and harness sections

* feat: update .gitignore to include .playwright-mcp and remove obsolete Playwright YAML file

* fix(docs): correct punctuation and formatting in documentation files

* feat(docs): remove outdated index.mdx file from documentation

* fix(docs): update documentation links and improve Chinese description in index.mdx

* fix(docs): update title in Chinese for meta information in _meta.ts
This commit is contained in:
JeffJiang
2026-04-03 07:25:40 +08:00
committed by GitHub
parent ef711a48b3
commit c1366cf559
55 changed files with 2245 additions and 29 deletions
+1 -8
View File
@@ -4,22 +4,15 @@ import { useEffect } from "react";
import { useI18nContext } from "./context";
import { getLocaleFromCookie, setLocaleInCookie } from "./cookies";
import { enUS } from "./locales/en-US";
import { zhCN } from "./locales/zh-CN";
import { translations } from "./translations";
import {
DEFAULT_LOCALE,
detectLocale,
normalizeLocale,
type Locale,
type Translations,
} from "./index";
const translations: Record<Locale, Translations> = {
"en-US": enUS,
"zh-CN": zhCN,
};
export function useI18n() {
const { locale, setLocale } = useI18nContext();
+10
View File
@@ -6,6 +6,16 @@ export function isLocale(value: string): value is Locale {
return (SUPPORTED_LOCALES as readonly string[]).includes(value);
}
export function getLocaleByLang(lang: string): Locale {
const normalizedLang = lang.toLowerCase();
for (const locale of SUPPORTED_LOCALES) {
if (locale.startsWith(normalizedLang)) {
return locale;
}
}
return DEFAULT_LOCALE;
}
export function normalizeLocale(locale: string | null | undefined): Locale {
if (!locale) {
return DEFAULT_LOCALE;
+6
View File
@@ -51,6 +51,12 @@ export const enUS: Translations = {
exportSuccess: "Conversation exported",
},
// Home
home: {
docs: "Docs",
blog: "Blog",
},
// Welcome
welcome: {
greeting: "Hello, again!",
+5
View File
@@ -40,6 +40,11 @@ export interface Translations {
exportSuccess: string;
};
home: {
docs: string;
blog: string;
};
// Welcome
welcome: {
greeting: string;
+6
View File
@@ -51,6 +51,12 @@ export const zhCN: Translations = {
exportSuccess: "对话已导出",
},
// Home
home: {
docs: "文档",
blog: "博客",
},
// Welcome
welcome: {
greeting: "你好,欢迎回来!",
+25 -1
View File
@@ -1,6 +1,7 @@
import { cookies } from "next/headers";
import { normalizeLocale, type Locale } from "./locale";
import { DEFAULT_LOCALE, normalizeLocale, type Locale } from "./locale";
import { translations } from "./translations";
export async function detectLocaleServer(): Promise<Locale> {
const cookieStore = await cookies();
@@ -15,3 +16,26 @@ export async function detectLocaleServer(): Promise<Locale> {
return normalizeLocale(locale);
}
export async function setLocale(locale: string | Locale): Promise<Locale> {
const normalizedLocale = normalizeLocale(locale);
const cookieStore = await cookies();
cookieStore.set("locale", encodeURIComponent(normalizedLocale), {
maxAge: 365 * 24 * 60 * 60,
path: "/",
sameSite: "lax",
});
return normalizedLocale;
}
export async function getI18n(localeOverride?: string | Locale) {
const locale = localeOverride
? normalizeLocale(localeOverride)
: await detectLocaleServer();
const t = translations[locale] ?? translations[DEFAULT_LOCALE];
return {
locale,
t,
};
}
+7
View File
@@ -0,0 +1,7 @@
import type { Locale } from "./locale";
import { enUS, zhCN, type Translations } from "./locales";
export const translations: Record<Locale, Translations> = {
"en-US": enUS,
"zh-CN": zhCN,
};