Add SEO and agent-readable documentation

This commit is contained in:
2026-08-14 21:10:52 +09:00
parent cda32cc260
commit e5c73c647d
26 changed files with 576 additions and 13 deletions
+40
View File
@@ -1,7 +1,47 @@
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',
},