import { defineConfig } from 'astro/config'; import sitemap from '@astrojs/sitemap'; const site = 'https://decodal.hareworks.net'; function alternateLinks(url) { const pathname = new URL(url).pathname; if (pathname === '/' || pathname === '/ja/') { return [ { url: `${site}/`, lang: 'en' }, { url: `${site}/ja/`, lang: 'ja' }, { url: `${site}/`, lang: 'x-default' }, ]; } const match = pathname.match(/^\/docs\/(en|ja)\/(.*)$/); if (!match) return undefined; const localizedPath = match[2]; return [ { url: `${site}/docs/en/${localizedPath}`, lang: 'en' }, { url: `${site}/docs/ja/${localizedPath}`, lang: 'ja' }, { url: `${site}/docs/en/${localizedPath}`, lang: 'x-default' }, ]; } export default defineConfig({ site, output: 'static', integrations: [ sitemap({ filter: (page) => { const pathname = new URL(page).pathname; return pathname !== '/docs/' && pathname !== '/404.html' && pathname !== '/404/' && !pathname.endsWith('.md') && !pathname.endsWith('.txt'); }, serialize(item) { const links = alternateLinks(item.url); return links ? { ...item, links } : item; }, }), ], build: { assets: 'assets', }, vite: { resolve: { dedupe: [ '@codemirror/language', '@codemirror/state', '@codemirror/view', '@lezer/highlight', '@lezer/lr', ], preserveSymlinks: true, }, }, });