layout.shared.tsx 2.0 KB

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