We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5fa14e3 commit 1970167Copy full SHA for 1970167
app/sitemap.ts
@@ -0,0 +1,24 @@
1
+import { headers } from "next/headers";
2
+import { getPostsForSite } from "@/lib/fetchers";
3
+
4
+export default async function Sitemap() {
5
+ const headersList = headers();
6
+ const domain =
7
+ headersList
8
+ .get("host")
9
+ ?.replace(".localhost:3000", `.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) ??
10
+ "vercel.pub";
11
12
+ const posts = await getPostsForSite(domain);
13
14
+ return [
15
+ {
16
+ url: `https://${domain}`,
17
+ lastModified: new Date(),
18
+ },
19
+ ...posts.map(({ slug }) => ({
20
+ url: `https://${domain}/${slug}`,
21
22
+ })),
23
+ ];
24
+}
0 commit comments