import type { EntryContext } from "react-router"; import { getSitemapXml } from "./utils/sitemap.server"; type Handler = (request: Request, remixContext: EntryContext) => Promise | null; const pathedRoutes: Record = { "/sitemap.xml": async (request, remixContext) => { const sitemap = await getSitemapXml(request, remixContext); return new Response(sitemap, { headers: { "Content-Type": "application/xml", "Content-Length": String(Buffer.byteLength(sitemap)), }, }); }, }; const routes: Array = [ ...Object.entries(pathedRoutes).map(([path, handler]) => { return (request: Request, remixContext: EntryContext) => { if (new URL(request.url).pathname !== path) return null; return handler(request, remixContext); }; }), ]; export { routes, pathedRoutes };