import { defineConfig, sharpImageService } from "astro/config";
import svelte from "@astrojs/svelte";
import tailwind from "@astrojs/tailwind";
import configureI18n from "./astro-i18n.adapter";
import sitemap from "@astrojs/sitemap";

import robotsTxt from "astro-robots-txt";
import path from "node:path";
import mdx from "@astrojs/mdx";

import starlight from "@astrojs/starlight";

// https://astro.build/config
export default defineConfig({
    output: "static",
    image: {
        service: sharpImageService(),
    },
    compressHTML: true,
    site: "https://steamwar.de",
    integrations: [
        svelte(),
        starlight({
            disable404Route: true,
            title: "SteamWar Docs",
            defaultLocale: "de",
            logo: {
                src: "./src/images/logo.png",
            },
            social: [
                { icon: "discord", label: "Discord", href: "https://steamwar.de/discord" },
                { icon: "document", label: "Gitea", href: "https://git.steamwar.de" },
            ],
            sidebar: [
                { label: "Startseite", slug: "docs" },
                { label: "Bau", badge: "WIP", items: ["docs/bausystem", { label: "Script System", items: ["docs/bausystem/script"] }] },
                { label: "Kampfsystem", badge: "WIP", items: ["docs/fightsystem"] },
                { label: "Minigames", badge: "WIP", items: ["docs/minigames"] },
                { label: "Schematicsystem", badge: "WIP", items: ["docs/schematicsystem"] },
                { label: "API", badge: "WIP", items: ["docs/api"] },
            ],
            editLink: {
                baseUrl: "https://git.steamwar.de/SteamWar/Website/src/branch/master/",
            },
        }),
        tailwind({
            configFile: "./tailwind.config.js",
            applyBaseStyles: false,
        }),
        configureI18n(),
        sitemap({
            i18n: {
                defaultLocale: "en",
                locales: {
                    en: "en-US",
                    de: "de-DE",
                },
            },
        }),
        robotsTxt({
            policy: [
                { userAgent: "*", disallow: ["/admin", "/login", "/dashboard", "/de", "/_astro"] },
                { userAgent: "anthropic-ai", disallow: "/" },
                { userAgent: "Applebot-Extended", disallow: "/" },
                { userAgent: "Bytespider", disallow: "/" },
                { userAgent: "CCBot", disallow: "/" },
                { userAgent: "ChatGPT-User", disallow: "/" },
                { userAgent: "ClaudeBot", disallow: "/" },
                { userAgent: "Claude-Web", disallow: "/" },
                { userAgent: "cohere-ai", disallow: "/" },
                { userAgent: "Diffbot", disallow: "/" },
                { userAgent: "FacebookBot", disallow: "/" },
                { userAgent: "GPTBot", disallow: "/" },
                { userAgent: "ImagesiftBot", disallow: "/" },
                { userAgent: "Meta-ExternalAgent", disallow: "/" },
                { userAgent: "Meta-ExternalFetcher", disallow: "/" },
                { userAgent: "omgili", disallow: "/" },
                { userAgent: "OmigliBot", disallow: "/" },
                { userAgent: "PerplexityBot", disallow: "/" },
                { userAgent: "Timpibot", disallow: "/" },
            ],
        }),
        mdx(),
    ],
    vite: {
        resolve: {
            alias: {
                "@components": path.resolve("./src/components"),
                "@pages": path.resolve("./src/pages"),
                "@styles": path.resolve("./src/styles"),
                "@utils": path.resolve("./src/util"),
                "@type": path.resolve("./src/components/types"),
                "@images": path.resolve("./src/images"),
                "@layouts": path.resolve("./src/layouts"),
                "@repo": path.resolve("./src/components/repo"),
                "@stores": path.resolve("./src/components/stores"),
                $lib: path.resolve("./src"),
            },
        },
    },
});
