import type { Config } from '@docusaurus/types'
import type * as Preset from '@docusaurus/preset-classic'
import { themes } from 'prism-react-renderer'
import { SITE_SOCIAL_PREVIEW_IMAGE } from './src/data/socialPreview'
import remarkMath from 'remark-math'
import rehypeKatex from 'rehype-katex'

const lightCodeTheme = themes.github
const darkCodeTheme = themes.vsDark
const siteUrl = 'https://vllm-semantic-router.com'
const siteDefaultDescription = 'Open-source LLM router for Mixture-of-Models. Route requests by cost, latency, privacy, safety, and modality across local, private, and frontier models.'
const siteSocialPreviewImageUrl = `${siteUrl}/${SITE_SOCIAL_PREVIEW_IMAGE}`

const config: Config = {
  title: 'vLLM Semantic Router',
  tagline: 'Open-source LLM router for Mixture-of-Models',
  favicon: 'img/vllm.png',

  // Set the production url of your site here
  url: siteUrl,
  // Set the /<baseUrl>/ pathname under which your site is served
  // For GitHub pages deployment, it is often '/<projectName>/'
  baseUrl: '/',

  // GitHub pages deployment config.
  // If you aren't using GitHub pages, you don't need these.
  organizationName: 'vllm-project', // Usually your GitHub org/user name.
  projectName: 'semantic-router', // Usually your repo name.

  // Even if you don't use internalization, you can use this field to set useful
  // metadata like html lang. For example, if your site is Chinese, you may want
  // to replace "en" with "zh-Hans".
  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'zh-Hans'],
    localeConfigs: {
      'en': { label: 'English', htmlLang: 'en-US' },
      'zh-Hans': { label: '简体中文', htmlLang: 'zh-Hans' },
    },
  },

  markdown: {
    mermaid: true,
    format: 'mdx',
    hooks: {
      onBrokenMarkdownLinks: 'warn',
    },
  },
  themes: ['@docusaurus/theme-mermaid'],

  presets: [
    [
      'classic',
      {
        docs: {
          beforeDefaultRemarkPlugins: [
            [remarkMath, {}],
          ],
          beforeDefaultRehypePlugins: [
            [rehypeKatex, {}],
          ],
          sidebarPath: './sidebars.ts',
          lastVersion: 'current',
          versions: {
            'current': {
              label: 'Latest',
              path: '',
              badge: true,
            },
            'v0.3': {
              label: 'v0.3',
              path: 'v0.3',
              badge: true,
            },
            'v0.2': {
              label: 'v0.2',
              path: 'v0.2',
              badge: true,
            },
            'v0.1': {
              label: 'v0.1',
              path: 'v0.1',
              badge: true,
            },
          },
          // Please change this to your repo.
          // Remove this to remove the "edit this page" links.
          // Custom editUrl function to always point to the "current" (main) version
          editUrl: ({ locale, docPath }) => {
            if (locale !== 'en') {
              return `https://github.com/vllm-project/semantic-router/edit/main/website/i18n/${locale}/docusaurus-plugin-content-docs/current/${docPath}`
            }
            return `https://github.com/vllm-project/semantic-router/edit/main/website/docs/${docPath}`
          },
        },
        blog: {
          showReadingTime: true,
          postsPerPage: 10,
          blogTitle: 'vLLM Semantic Router Blog',
          blogDescription: 'Latest updates, insights, and technical articles about vLLM Semantic Router',
          blogSidebarTitle: 'Recent Posts',
          blogSidebarCount: 10,
          // Please change this to your repo.
          // Remove this to remove the "edit this page" links.
          editUrl:
            'https://github.com/vllm-project/semantic-router/tree/main/website/blog/',
        },
        theme: {
          customCss: './src/css/custom.css',
        },
        sitemap: {
          changefreq: 'weekly',
          priority: 0.5,
          filename: 'sitemap.xml',
          ignorePatterns: ['/tags/**', '/search'],
        },
      } satisfies Preset.Options,
    ],
  ],

  plugins: [
    [
      '@docusaurus/plugin-client-redirects',
      {
        redirects: [
          {
            from: '/docs/installation/kubernetes',
            to: '/docs/installation/k8s/ai-gateway',
          },
          {
            from: '/docs/cli/overview',
            to: '/docs/installation/',
          },
          {
            from: '/docs/cli/commands-reference',
            to: '/docs/installation/',
          },
          {
            from: '/docs/cli/troubleshooting',
            to: '/docs/troubleshooting/common-errors',
          },
          {
            from: '/docs/tutorials/signal/projections',
            to: '/docs/tutorials/projection/overview',
          },
          {
            from: '/docs/tutorials/signal/heuristic/modality',
            to: '/docs/tutorials/signal/learned/modality',
          },
        ],
      },
    ],
  ],

  themeConfig: {
    image: SITE_SOCIAL_PREVIEW_IMAGE,
    metadata: [
      { name: 'description', content: siteDefaultDescription },
      { name: 'keywords', content: 'open-source LLM router, multi-model routing, semantic router, model selection, AI gateway, vLLM, Envoy, inference routing, policy-aware routing, privacy-aware routing, safety routing' },
      { name: 'author', content: 'vLLM Semantic Router Team' },
      { name: 'application-name', content: 'vLLM Semantic Router' },
      { property: 'og:title', content: 'vLLM Semantic Router | Open-Source LLM Router' },
      { property: 'og:description', content: siteDefaultDescription },
      { property: 'og:type', content: 'website' },
      { property: 'og:site_name', content: 'vLLM Semantic Router' },
      { property: 'og:image', content: siteSocialPreviewImageUrl },
      { property: 'og:image:alt', content: 'vLLM Semantic Router social preview' },
      { name: 'twitter:card', content: 'summary_large_image' },
      { name: 'twitter:title', content: 'vLLM Semantic Router | Open-Source LLM Router' },
      { name: 'twitter:description', content: siteDefaultDescription },
      { name: 'twitter:image', content: siteSocialPreviewImageUrl },
      { name: 'twitter:image:alt', content: 'vLLM Semantic Router social preview' },

      // GEO metadata config
      { name: 'geo.region', content: 'US-CA' },
      { name: 'geo.placename', content: 'San Francisco' },
      { name: 'geo.position', content: '37.7749;-122.4194' },
      { name: 'ICBM', content: '37.7749, -122.4194' },
    ],
    navbar: {
      title: 'vLLM-SR',
      logo: {
        alt: 'vLLM Semantic Router Logo',
        src: 'img/vllm.png',
        srcDark: 'img/vllm.png',
      },
      items: [
        {
          type: 'localeDropdown',
          className: 'nav-locale',
          position: 'right',
        },
        {
          type: 'docsVersionDropdown',
          position: 'right',
          dropdownActiveClassDisabled: true,
        },
        {
          type: 'docSidebar',
          sidebarId: 'tutorialSidebar',
          className: 'nav-primary',
          position: 'left',
          label: 'Docs',
        },
        {
          type: 'dropdown',
          className: 'nav-primary',
          label: 'Research',
          position: 'left',
          items: [
            {
              label: 'Paper & Talks',
              to: '/publications',
            },
            {
              label: 'White Paper',
              to: '/white-paper',
            },
            {
              label: 'Vision Paper',
              to: '/vision-paper',
            },
          ],
        },
        {
          to: '/blog',
          className: 'nav-primary',
          label: 'Blog',
          position: 'left',
        },

        {
          type: 'dropdown',
          className: 'nav-primary',
          label: 'Community',
          position: 'left',
          items: [
            {
              label: 'Governance',
              to: '/community/team',
            },
            {
              label: 'Working Group',
              to: '/community/work-groups',
            },
            {
              label: 'Contributing Guide',
              to: '/community/contributing',
            },
            {
              label: 'Code of Conduct',
              to: '/community/code-of-conduct',
            },

            {
              type: 'html',
              value: '<hr style="margin: 0.3rem 0;">',
            },
            {
              label: 'GitHub Issues',
              href: 'https://github.com/vllm-project/semantic-router/issues',
            },
          ],
        },
        {
          to: '/community/contributors',
          className: 'nav-primary',
          label: 'Leaderboard',
          position: 'left',
        },
        {
          label: 'GitHub',
          href: 'https://github.com/vllm-project/semantic-router',
          className: 'nav-utility',
          position: 'right',
        },
        {
          label: 'Models',
          href: 'https://huggingface.co/LLM-Semantic-Router',
          className: 'nav-utility',
          position: 'right',
        },
      ],
    },
    footer: {
      style: 'light',
      links: [
        {
          title: 'Documentation',
          items: [
            {
              label: 'Quick Start',
              to: '/docs/intro',
            },
            {
              label: 'Installation',
              to: '/docs/installation',
            },
            {
              label: 'Governance',
              to: '/community/team',
            },
            {
              label: 'Contributing',
              to: '/community/contributing',
            },
          ],
        },
        {
          title: 'Community',
          items: [
            {
              label: 'GitHub',
              href: 'https://github.com/vllm-project/semantic-router',
            },
            {
              label: 'Hugging Face',
              href: 'https://huggingface.co/LLM-Semantic-Router',
            },
            {
              label: 'GitHub Discussions',
              href: 'https://github.com/vllm-project/semantic-router/discussions',
            },
            {
              label: 'Leaderboard',
              to: '/community/contributors',
            },
          ],
        },
        {
          title: 'More',
          items: [
            {
              label: 'Blog',
              to: '/blog',
            },
            {
              label: 'Publications',
              to: '/publications',
            },
            {
              label: 'White Paper',
              to: '/white-paper',
            },
            {
              label: 'Vision Paper',
              to: '/vision-paper',
            },

            {
              label: 'License',
              href: 'https://github.com/vllm-project/semantic-router/blob/main/LICENSE',
            },
          ],
        },
      ],
      copyright: `Copyright © ${new Date().getFullYear()} vLLM Semantic Router Team. Built with Docusaurus.`,
    },
    prism: {
      theme: lightCodeTheme,
      darkTheme: darkCodeTheme,
      additionalLanguages: ['bash', 'json', 'yaml', 'go', 'rust', 'python'],
    },
    colorMode: {
      defaultMode: 'light',
      disableSwitch: true,
      respectPrefersColorScheme: false,
    },
  } satisfies Preset.ThemeConfig,
  headTags: [
    {
      tagName: 'script',
      attributes: { type: 'application/ld+json' },
      innerHTML: JSON.stringify({
        '@context': 'https://schema.org',
        '@type': 'SoftwareApplication',
        'name': 'vLLM Semantic Router',
        'applicationCategory': 'AIInfrastructure',
        'operatingSystem': 'Cross-platform',
        'description': 'Open-source LLM router for Mixture-of-Models',
        'url': 'https://vllm-semantic-router.com',
        'publisher': {
          '@type': 'Organization',
          'name': 'vLLM Semantic Router Team',
          'url': 'https://github.com/vllm-project/semantic-router',
        },
      }),
    },
  ],
}

export default config
