diff --git a/website/src/components/templates/BaseTemplate.tsx b/website/src/components/templates/BaseTemplate.tsx index 5feed39979..104f4125e2 100644 --- a/website/src/components/templates/BaseTemplate.tsx +++ b/website/src/components/templates/BaseTemplate.tsx @@ -64,6 +64,8 @@ export const BaseTemplate: FC = ({ + + { }); }); +app.get("/sitemap.xml", (c) => { + const routes = ["/", ...flattenedPages.map((page) => page.route)]; + const today = new Date(); + const formattedDate = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, "0")}-${String(today.getDate()).padStart(2, "0")}`; + + const sitemap = ` + +${routes + .map( + (route) => ` + https://typst-jp.github.io${route} + ${formattedDate} + `, + ) + .join("\n")} + +`; + + return c.text(sitemap, 200, { + "Content-Type": "application/xml", + }); +}); + +app.get("/robots.txt", (c) => { + const robotsTxt = `User-agent: * +Allow: / + +Sitemap: https://typst-jp.github.io/sitemap.xml +`; + + return c.text(robotsTxt, 200, { + "Content-Type": "text/plain", + }); +}); + export default app;