import { defineConfig, envField } from "astro/config";
import solidJs from "@astrojs/solid-js";
import mdx from "@astrojs/mdx";
import icon from "astro-icon";
import paths from "node:path";
import rehypeBuckTable from "~/support/rehype-buck-tables";

// https://astro.build/config
export default defineConfig({
  env: {
    schema: {
      VISIBLE_DRAFT: envField.boolean({
        context: "server",
        access: "public",
        default: false,
      }),
    },
  },
  integrations: [
    solidJs(),
    mdx(),
    icon(),
    {
      name: "inject-cloudflare-headers",
      hooks: {
        "astro:config:setup": ({ injectRoute }) => {
          injectRoute({
            pattern: "/_headers",
            entrypoint: "./src/pages/_headers.ts",
          });
        },
      },
    },
  ],
  markdown: {
    rehypePlugins: [rehypeBuckTable],
    shikiConfig: {
      themes: {
        light: "github-light",
        dark: "github-dark",
      },
    },
  },
  vite: {
    resolve: {
      alias: {
        "~": paths.resolve(import.meta.dir, "src"),
      },
    },
  },
});