import type { EntryContext } from 'remix' ; import { getSitemapXml } from './utils/sitemap.server' ; type Handler = ( request : Request , remixContext : EntryContext ) => Promise < Response | null > | null ; const pathedRoutes = { '/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 = [ ... Object . entries ( pathedRoutes ) . map ( ( [ path , handler ] ) => { return ( request , remixContext ) => { if ( new URL ( request . url ) . pathname !== path ) return null ; return handler ( request , remixContext ) ; } ; } ) , ] ; export { routes , pathedRoutes } ;