layout.shared.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 { appName, productRepoUrl, telegramChannel, telegramChannelUrl, donateUrl } from './shared';
  6. import { getSiteMessages } from './site-i18n';
  7. // Build locale-aware shared layout options. With `hideLocale: 'default-locale'`,
  8. // English URLs have no prefix while other locales are prefixed (`/fa`, `/ru`, `/zh`).
  9. export function baseOptions(lang: string): BaseLayoutProps {
  10. const prefix = lang === 'en' ? '' : `/${lang}`;
  11. const m = getSiteMessages(lang);
  12. return {
  13. nav: {
  14. title: (
  15. <span className="inline-flex items-center gap-2 font-semibold">
  16. <Logo className="h-6" />
  17. {appName}
  18. </span>
  19. ),
  20. url: `${prefix}/`,
  21. },
  22. githubUrl: productRepoUrl,
  23. links: [
  24. {
  25. text: m.documentation,
  26. url: `${prefix}/docs`,
  27. active: 'nested-url',
  28. },
  29. {
  30. type: 'icon',
  31. label: `Telegram channel (@${telegramChannel})`,
  32. icon: <TelegramIcon />,
  33. text: 'Telegram',
  34. url: telegramChannelUrl,
  35. external: true,
  36. },
  37. // Compact heart icon in the top nav bars (home + docs).
  38. {
  39. type: 'icon',
  40. on: 'nav',
  41. label: m.donate,
  42. icon: <Heart />,
  43. text: m.donate,
  44. url: donateUrl,
  45. external: true,
  46. },
  47. // Prominent labelled entry in the docs sidebar / mobile menu.
  48. {
  49. type: 'main',
  50. on: 'menu',
  51. icon: <Heart />,
  52. text: m.donate,
  53. url: donateUrl,
  54. external: true,
  55. },
  56. ],
  57. };
  58. }