mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-10 06:36:06 +00:00
9b91f0f42e
Fold the standalone 3x-ui-docs project (Next.js 16 + Fumadocs, deployed to docs.sanaei.dev) into docs/ so the panel and its documentation share a single source of truth, the way sing-box keeps its docs in-tree. The old repo becomes redundant and can be retired. - Import the full site under docs/ (app, components, content, lib, public, scripts, config). The self-contained pnpm project sits alongside the existing engineering notes with no filename collisions. - Re-point "Edit on GitHub" links from MHSanaei/3x-ui-docs to this repo's docs/content/docs path (docs/lib/shared.ts, docs/app/.../page.tsx). - Add docs-ci.yml and docs-deploy.yml under .github/workflows/, scoped to docs/** and run with working-directory: docs, since GitHub only runs workflows from the repo-root .github/. deploy-static.yml's GitHub Pages publish (CNAME docs.sanaei.dev) carries over unchanged. Follow-up (outside this commit): attach the docs.sanaei.dev custom domain to this repository's Pages (or set the Vercel project's root directory to docs), confirm the site is live from the monorepo, then delete MHSanaei/3x-ui-docs.
46 lines
2.0 KiB
TypeScript
46 lines
2.0 KiB
TypeScript
import Link from 'next/link';
|
|
import { Languages } from 'lucide-react';
|
|
import { i18n, locales } from '@/lib/i18n';
|
|
import { cn } from '@/lib/cn';
|
|
|
|
// Home-navbar language switcher.
|
|
//
|
|
// fumadocs' built-in popover switcher (`LanguageSelect`) has its item clicks
|
|
// swallowed when it is nested inside HomeLayout's Radix `NavigationMenu` — the
|
|
// dropdown opens but selecting a locale never fires `onChange`/`router.push`.
|
|
// The docs sidebar isn't wrapped in a NavigationMenu, so the built-in one works
|
|
// there and is kept. Here we use a native `<details>` toggle + real `<Link>`
|
|
// anchors, which navigate reliably inside the navbar (like the other nav links).
|
|
//
|
|
// The home navbar only renders on the landing page, so the targets are simply
|
|
// each locale's home (`/`, `/fa`, `/ru`, `/zh`).
|
|
export function HomeLanguageSwitcher({ current }: { current: string }) {
|
|
return (
|
|
<details className="group relative [&>summary::-webkit-details-marker]:hidden">
|
|
<summary
|
|
aria-label="Choose a language"
|
|
className="flex cursor-pointer list-none items-center rounded-lg p-1.5 text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground group-open:bg-fd-accent"
|
|
>
|
|
<Languages className="size-5" />
|
|
</summary>
|
|
<div className="absolute end-0 z-50 mt-1.5 flex min-w-40 flex-col gap-0.5 rounded-lg border bg-fd-popover p-1 text-fd-popover-foreground shadow-lg">
|
|
<p className="p-2 text-xs font-medium text-fd-muted-foreground">Choose a language</p>
|
|
{locales.map(({ locale, name }) => (
|
|
<Link
|
|
key={locale}
|
|
href={locale === i18n.defaultLanguage ? '/' : `/${locale}`}
|
|
className={cn(
|
|
'rounded-md px-2 py-1.5 text-start text-sm transition-colors',
|
|
locale === current
|
|
? 'bg-fd-primary/10 text-fd-primary'
|
|
: 'text-fd-muted-foreground hover:bg-fd-accent hover:text-fd-accent-foreground',
|
|
)}
|
|
>
|
|
{name}
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</details>
|
|
);
|
|
}
|