diff --git a/apps/web/app/sitemap.ts b/apps/web/app/sitemap.ts new file mode 100644 index 0000000..f4c69df --- /dev/null +++ b/apps/web/app/sitemap.ts @@ -0,0 +1,28 @@ +import { getCampuses } from "@/lib/campus"; +import { MetadataRoute } from "next"; + +export default async function sitemap(): Promise { + const baseurl = "https://callmap.app"; + + const response = await getCampuses(); + + const campuses = response?.map((campus) => { + return { url: `${baseurl}/${campus?.campus_id}`, lastModified: new Date() }; + }); + + return [ + { + url: `${baseurl}/`, + lastModified: new Date(), + }, + { + url: `${baseurl}/blog`, + lastModified: new Date(), + }, + { + url: `${baseurl}/docs`, + lastModified: new Date(), + }, + ...(campuses as { url: string; lastModified: Date }[]), + ]; +} diff --git a/apps/web/lib/campus.ts b/apps/web/lib/campus.ts index 118215d..f276f22 100644 --- a/apps/web/lib/campus.ts +++ b/apps/web/lib/campus.ts @@ -1,5 +1,10 @@ import { supabase } from "./supabase/client"; +export async function getCampuses() { + const { data: campuses } = await supabase.from("campuses").select("*"); + return campuses; +} + export async function getCampus(campusid: string) { const { data: campus } = await supabase .from("campuses")