// @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'

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

export default defineConfig({
  site: getSiteURL(),

  prefetch: true,

  integrations: [
    sitemap(),
    starlight({
      title: "Alex Lebens Docs",
      head: [
        {
          tag: 'script',
          attrs: {
            src: 'https://rybbit.alexlebens.dev/api/script.js',
            'data-site-id': 'a8768eb5f5ff',
            defer: true,
          },
        },
      ],
      customCss: [
        './src/styles/custom.css',
      ],
      expressiveCode: {
        themes: ['vitesse-light', 'vitesse-dark'],
      },      
      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",
          collapsed: true,
          autogenerate: { directory: "applications" },
        },
      ],
    })  
  ],

  output: 'static',

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