mirror of
https://github.com/Hackdex-App/hackdex-website.git
synced 2026-03-30 22:25:38 -05:00
Add dynamic sitemap
This commit is contained in:
parent
1d7d0898eb
commit
b219873dfb
25
src/app/sitemap.ts
Normal file
25
src/app/sitemap.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { createClient } from "@/utils/supabase/server";
|
||||
import { MetadataRoute } from "next";
|
||||
|
||||
export default async function Sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
let routes: MetadataRoute.Sitemap = [
|
||||
{ url: "/", lastModified: new Date().toISOString() },
|
||||
{ url: "/discover", lastModified: new Date().toISOString(), changeFrequency: "daily" as const },
|
||||
];
|
||||
|
||||
const supabase = await createClient();
|
||||
|
||||
const { data: hacks } = await supabase.from("hacks").select("slug,updated_at");
|
||||
if (hacks) {
|
||||
routes.push(...hacks.map((hack) => ({
|
||||
url: `/hack/${hack.slug}`,
|
||||
changeFrequency: "weekly" as const,
|
||||
lastModified: hack.updated_at || new Date().toISOString(),
|
||||
})));
|
||||
}
|
||||
|
||||
return routes.map((route) => ({
|
||||
...route,
|
||||
url: `${process.env.NEXT_PUBLIC_SITE_URL!}/${route.url}`,
|
||||
}));
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user