Capital/server/api/sitemap/posts.ts

14 lines
464 B
TypeScript
Raw Permalink Normal View History

export default defineSitemapEventHandler(async () => {
const config = useRuntimeConfig();
const res = await fetch(`${config.public.solarNetworkApi}/cgi/co/posts/minimal?take=500`)
const result = await res.json()
return result.data.map((item: any) => asSitemapUrl({
2024-08-17 14:38:13 +00:00
loc: item.alias ? `/posts/${item.area_alias}/${item.alias}` : `/posts/${item.id}`,
2024-08-16 08:53:23 +00:00
lastmod: item.edited_at ?? item.published_at,
2024-08-17 02:32:24 +00:00
priority: 0.7,
_sitemap: "posts",
}));
})