// @ts-check
import { defineConfig } from "astro/config";
import mdx from "@astrojs/mdx";
import rehypeKatex from "rehype-katex";
import remarkGfm from "remark-gfm";
import remarkMath from "remark-math";
import sitemap from "@astrojs/sitemap";

import react from "@astrojs/react";
// @ts-ignore - TailwindCSS v4 Vite plugin has type compatibility issues with Astro
import tailwindcss from "@tailwindcss/vite";
import remarkCallouts from "./src/remark/callouts.mjs";
import remarkCodeFenceLanguages from "./src/remark/code-fence-languages.mjs";
import remarkInlineFootnotes from "./src/remark/inline-footnotes.mjs";
import remarkSemanticBlocks from "./src/remark/semantic-blocks.mjs";
import remarkSymbols from "./src/remark/symbols.mjs";
import remarkTypography from "./src/remark/typography.mjs";
import { ACTIVE_BLOG_SITE } from "./src/blog-sites.js";

const remarkPlugins = [
  remarkGfm,
  remarkInlineFootnotes,
  remarkCodeFenceLanguages,
  remarkSemanticBlocks,
  remarkMath,
  remarkTypography,
  remarkCallouts,
  remarkSymbols,
];
const rehypePlugins = [rehypeKatex];

// https://astro.build/config
export default defineConfig({
  site: ACTIVE_BLOG_SITE.url,
  integrations: [mdx({ remarkPlugins, rehypePlugins }), sitemap(), react()],
  markdown: {
    remarkPlugins,
    rehypePlugins,
  },
  output: "static",
  outDir: "dist",

  vite: {
    // @ts-ignore - Suppress TypeScript error for TailwindCSS v4 plugin compatibility
    plugins: [tailwindcss()],
  },
});
