Files

16 lines
594 B
TypeScript

import type { MetadataRoute } from 'next';
import { getWebRuntimeAPI } from '#web-runtime/api/web-runtime-api';
import { siteUrl } from '#web-runtime/lib/site-url';
import { buildSitemap } from '#web-runtime/lib/sitemap';
import { getPathname } from '#i18n/navigation';
function publicPath(locale: string, path: string): string {
return getPathname({ locale, href: path ? `/${path}` : '/' });
}
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const entries = await getWebRuntimeAPI().listSitemapPages();
return buildSitemap(entries, siteUrl(), publicPath);
}