layout.shared.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
  2. import { Heart } from 'lucide-react';
  3. import { Logo } from '@/components/logo';
  4. import { TelegramIcon } from '@/components/icons';
  5. import { DocsThemeSwitch } from '@/components/theme-switch';
  6. import { appName, productRepoUrl, telegramChannel, telegramChannelUrl, donateUrl, siteUrl } from './shared';
  7. import { getSiteMessages } from './site-i18n';
  8. // Build locale-aware shared layout options. With `hideLocale: 'default-locale'`,
  9. // English URLs have no prefix while other locales are prefixed (`/fa`, `/ru`, `/zh`).
  10. export function baseOptions(lang: string): BaseLayoutProps {
  11. const prefix = lang === 'en' ? '' : `/${lang}`;
  12. const m = getSiteMessages(lang);
  13. return {
  14. slots: {
  15. themeSwitch: DocsThemeSwitch,
  16. },
  17. nav: {
  18. title: (
  19. <span className="inline-flex items-center gap-2 font-semibold">
  20. <Logo className="h-6" />
  21. {appName}
  22. </span>
  23. ),
  24. url: `${prefix}/`,
  25. },
  26. githubUrl: productRepoUrl,
  27. links: [
  28. {
  29. text: m.documentation,
  30. url: `${prefix}/docs`,
  31. active: 'nested-url',
  32. },
  33. // Live component workbench built from frontend/ and published alongside the docs.
  34. {
  35. text: 'Storybook',
  36. url: `${siteUrl}/storybook/`,
  37. external: true,
  38. },
  39. {
  40. type: 'icon',
  41. label: `Telegram channel (@${telegramChannel})`,
  42. icon: <TelegramIcon />,
  43. text: 'Telegram',
  44. url: telegramChannelUrl,
  45. external: true,
  46. },
  47. // Compact heart icon in the top nav bars (home + docs).
  48. {
  49. type: 'icon',
  50. on: 'nav',
  51. label: m.donate,
  52. icon: <Heart />,
  53. text: m.donate,
  54. url: donateUrl,
  55. external: true,
  56. },
  57. // Prominent labelled entry in the docs sidebar / mobile menu.
  58. {
  59. type: 'main',
  60. on: 'menu',
  61. icon: <Heart />,
  62. text: m.donate,
  63. url: donateUrl,
  64. external: true,
  65. },
  66. ],
  67. };
  68. }