-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a109ea1
commit b80bd56
Showing
4 changed files
with
4,389 additions
and
3,320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { generateSitemap } from "@nasa-gcn/remix-seo"; | ||
import { type LoaderFunctionArgs, type ServerBuild } from "@remix-run/node"; | ||
|
||
export async function loader({ request }: LoaderFunctionArgs) { | ||
const serverBuild = await getBuild(); | ||
|
||
return generateSitemap(request, serverBuild.routes, { | ||
siteUrl: getDomainUrl(request), | ||
}); | ||
} | ||
|
||
async function getBuild() { | ||
return (await (import.meta.env.DEV | ||
? //@ts-ignore | ||
import("../../build/server/index.js") | ||
: import( | ||
/* @vite-ignore */ | ||
import.meta.resolve("../../build/server/index.js") | ||
))) as unknown as ServerBuild; | ||
} | ||
|
||
function getDomainUrl(request: Request) { | ||
const host = | ||
request.headers.get("X-Forwarded-Host") ?? | ||
request.headers.get("host") ?? | ||
new URL(request.url).host; | ||
const protocol = host.includes("localhost") ? "http" : "https"; | ||
return `${protocol}://${host}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.