import { defineConfig } from "astro/config";
import tailwindcss from "@tailwindcss/vite";
import sitemap from "@astrojs/sitemap";
import remarkToc from "remark-toc";
import remarkCollapse from "remark-collapse";
import umami from "@yeskunall/astro-umami";
import rehypeCallouts from "rehype-callouts";

import { SITE } from "./src/config";

import expressiveCode from "astro-expressive-code";

// https://astro.build/config
export default defineConfig({
  site: SITE.website,
  integrations: [
    sitemap({
      filter: (page) => SITE.showArchives || !page.endsWith("/archives"),
    }),
    expressiveCode(),
    umami({ id: "a16cd27f-5d49-4a75-a710-3e541fe3bea0" }),
  ],
  markdown: {
    remarkPlugins: [remarkToc, [remarkCollapse, { test: "Table of contents" }]],
    rehypePlugins: [rehypeCallouts],
    shikiConfig: {
      // For more themes, visit https://shiki.style/themes
      themes: { light: "catppuccin-latte", dark: "catppuccin-frappe" },
      wrap: true,
    },
  },
  vite: {
    plugins: [tailwindcss()],
    optimizeDeps: {
      exclude: ["@resvg/resvg-js"],
    },
  },
  image: {
    // Used for all Markdown images; not configurable per-image
    // Used for all `<Image />` and `<Picture />` components unless overridden with a prop
    experimentalLayout: "full-width",
  },
  // experimental: {
  //   responsiveImages: true,
  // },
});
