// @ts-check
import { defineConfig } from "astro/config";

import node from "@astrojs/node";
import sitemap from '@astrojs/sitemap';
import starlight from "@astrojs/starlight";
import starlightThemeRapide from 'starlight-theme-rapide'

import tailwindcss from '@tailwindcss/vite';

const getSiteURL = () => {
  if (process.env.SITE_URL) {
    return `https://${process.env.SITE_URL}`;
  }
  return "http://localhost:4321";
};

export default defineConfig({
  site: getSiteURL(),

  security: { csp: true },

  prefetch: true,

  integrations: [
    sitemap(),
    starlight({
      title: "Alex Lebens Docs",
      customCss: [
        './src/styles/custom.css',
      ],
      social: [
        {
          icon: "external",
          label: "Homepage",
          href: "https://www.alexlebens.dev",
        },
      ],
      plugins: [
        starlightThemeRapide()
      ],
      sidebar: [
        {
          label: "Reference",
          autogenerate: { directory: "reference" },
        },
        {
          label: "Guides",
          autogenerate: { directory: "guides" },
        },
        {
          label: "Applications",
          autogenerate: { directory: "applications" },
        },
      ],
    }),
  ],

  markdown: {
    syntaxHighlight: false,
  },

  plugins: {
    '@tailwindcss/postcss': {},
  },

  vite: {
    plugins: [tailwindcss()],
  },

  output: 'static',

  adapter: node({
    mode: 'standalone',
  }),
});
