import { themes as prismThemes } from "prism-react-renderer";
import type { Config } from "@docusaurus/types";
import type * as Preset from "@docusaurus/preset-classic";

const config: Config = {
  title: "TP-Docs",
  tagline: "Your Source of Truth for Engineering Docs",
  favicon: "img/favicon.png",

  future: { v4: true },

  url: "https://docs.dffm.it",
  baseUrl: "/",

  organizationName: "marco.costalunga",
  projectName: "tp-docs",

  onBrokenLinks: "throw",
  onBrokenMarkdownLinks: "warn",

  i18n: { defaultLocale: "it", locales: ["it"] },

  presets: [
    [
      "classic",
      {
        theme: { customCss: "./src/css/custom.css" },
        docs: {
          sidebarPath: "./sidebars.ts",
          editUrl: "https://gitlab.dffm.it/giuseppe/docs/-/edit/main/",
        },
        blog: {
          showReadingTime: true,
          feedOptions: { type: ["rss", "atom"], xslt: true },
          editUrl: "https://gitlab.dffm.it/giuseppe/docs/-/edit/main/",
          onInlineTags: "warn",
          onInlineAuthors: "warn",
          onUntruncatedBlogPosts: "warn",
        },
      } satisfies Preset.Options,
    ],
  ],

  themes: [
    "@docusaurus/theme-mermaid", // ✅ aggiunta qui
    [
      require.resolve("@easyops-cn/docusaurus-search-local"),
      { hashed: true, language: ["it"] },
    ],
  ],

  plugins: [
    [
      "@docusaurus/plugin-pwa",
      {
        debug: true,
        offlineModeActivationStrategies: ["appInstalled", "standalone", "queryString"],
        pwaHead: [
          { tagName: "link", rel: "icon", href: "/img/favicon.png" },
          { tagName: "link", rel: "manifest", href: "/manifest.json" },
          { tagName: "meta", name: "theme-color", content: "rgb(37, 194, 160)" },
        ],
      },
    ],
  ],

  markdown: { mermaid: true }, // ✅ abilita parsing mermaid nei .md/.mdx

  themeConfig: {
    image: "img/docusaurus-social-card.jpg",
    navbar: {
      title: "TP-Docs",
      logo: { alt: "My Site Logo", src: "img/favicon.png" },
      items: [
        { type: "docSidebar", sidebarId: "docSidebar", position: "left", label: "Documentazione" },
        { to: "/blog", label: "Blog", position: "left" },
      ],
    },
    footer: {
      style: "dark",
      copyright: `Copyright © ${new Date().getFullYear()} Tecno Pack SPA. Built with Docusaurus.`,
    },
    prism: {
      theme: prismThemes.github,
      darkTheme: prismThemes.vsDark,
      additionalLanguages: ["yaml", "csharp", "iecst", "bash"],
    },
  } satisfies Preset.ThemeConfig,
};

export default config;
