avior.me/src/pages/sitemap.xml.ts
Florian Bouillon 3fc900a1e6
All checks were successful
Build, check & Test / run (push) Successful in 1m41s
Update src/pages/index.astro (#1)
Reviewed-on: #1
2023-11-25 22:50:55 +00:00

30 lines
600 B
TypeScript

import type { APIRoute } from 'astro'
import { getCollection } from 'astro:content'
import Sitemap from 'easy-sitemap'
const projects = await getCollection('projects')
/**
* sitemap generation
*/
export const ALL: APIRoute = async () => {
const sitemap = new Sitemap('https://avior.me')
sitemap.addEntry('/', {
priority: 1
})
sitemap.addEntry('/projects/', {
priority: 0.5
})
for (const project of projects) {
sitemap.addEntry('/projects/' + project.slug, {
priority: 0.7
})
}
return new Response(sitemap.build(), {
headers: {
'Content-Type': 'application/xml'
}
})
}