import { defineConfig } from "astro/config";
import tailwindcss from "@tailwindcss/vite";
import sitemap from "@astrojs/sitemap";
import compressor from "astro-compressor";
import starlight from "@astrojs/starlight";
import node from "@astrojs/node";
import react from "@astrojs/react";

import mdx from "@astrojs/mdx";


// https://astro.build/config
export default defineConfig({
  adapter: node({
    mode: "standalone"
  }),
  // https://docs.astro.build/en/guides/images/#authorizing-remote-images
  site: "https://isharetone.com",
  image: {
    domains: ["images.unsplash.com"],
  },
  i18n: {
    defaultLocale: "en",
    locales: ["en", "es"],
    routing: {
      prefixDefaultLocale: true,
    },
  },
  prefetch: true,
  integrations: [react(), sitemap({
    i18n: {
      defaultLocale: "en", // All urls that don't contain language prefix after `https://screwfast.uk/` will be treated as default locale, i.e. `en`
      locales: {
        en: "en", // The `defaultLocale` value must present in `locales` keys
        es: "es",
        pt: "pt",
        ja: "ja",
      },
      routing: {
        prefixDefaultLocale: true, // This enables the /en prefix
      },
    },
  }), starlight({
    title: "ScrewFast Docs",
    // Starlight will use the Astro i18n configuration automatically
    // https://starlight.astro.build/guides/sidebar/
    sidebar: [
      {
        label: "Quick Start Guides",
        translations: {
          es: "Guías de Inicio Rápido",
          pt: "Guias de Início Rápido",
          ja: "クイックスタートガイド",
        },
        items: [{ autogenerate: { directory: "guides" } }],
      },
      {
        label: "Tools & Equipment",
        items: [
          { label: "Tool Guides", link: "tools/tool-guides/" },
          { label: "Equipment Care", link: "tools/equipment-care/" },
        ],
      },
      {
        label: "Construction Services",
        items: [{ autogenerate: { directory: "construction" } }],
      },
      {
        label: "Advanced Topics",
        items: [{ autogenerate: { directory: "advanced" } }],
      },
    ],
    social: [
      { icon: "github", label: "GitHub", href: "https://github.com/mearashadowfax/ScrewFast" },
    ],
    disable404Route: true,
    customCss: ["./src/assets/styles/starlight.css"],
    favicon: "/favicon.ico",
    components: {
      SiteTitle: "./src/components/ui/starlight/SiteTitle.astro",
      Head: "./src/components/ui/starlight/Head.astro",
      MobileMenuFooter: "./src/components/ui/starlight/MobileMenuFooter.astro",
      ThemeSelect: "./src/components/ui/starlight/ThemeSelect.astro",
    },
    head: [
      {
        tag: "meta",
        attrs: {
          property: "og:image",
          content: "https://screwfast.uk" + "/social.webp",
        },
      },
      {
        tag: "meta",
        attrs: {
          property: "twitter:image",
          content: "https://screwfast.uk" + "/social.webp",
        },
      },
    ],
  }), compressor({
    gzip: false,
    brotli: true,
  }), mdx()],
  experimental: {
    clientPrerender: true,
  },
  vite: {
    plugins: [tailwindcss()],
  },
});

