Add SEO and agent-readable documentation
This commit is contained in:
@@ -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',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user