mirror of
https://github.com/penxio/penx.git
synced 2026-04-19 03:03:06 -04:00
25 lines
578 B
TypeScript
25 lines
578 B
TypeScript
import { headers } from "next/headers";
|
|
import { getPostsForSpace } from "@/lib/fetchers";
|
|
|
|
export default async function Sitemap() {
|
|
const headersList = headers();
|
|
const domain =
|
|
headersList
|
|
.get("host")
|
|
?.replace(".localhost:3000", `.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) ??
|
|
"vercel.pub";
|
|
|
|
const posts = await getPostsForSpace(domain);
|
|
|
|
return [
|
|
{
|
|
url: `https://${domain}`,
|
|
lastModified: new Date(),
|
|
},
|
|
...posts.map(({ slug }) => ({
|
|
url: `https://${domain}/${slug}`,
|
|
lastModified: new Date(),
|
|
})),
|
|
];
|
|
}
|