Skip to content

Commit

Permalink
Dynamic sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
brandnholl committed Apr 10, 2024
1 parent e2d0e3c commit 7ed43a4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
28 changes: 28 additions & 0 deletions apps/web/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { getCampuses } from "@/lib/campus";
import { MetadataRoute } from "next";

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
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 }[]),
];
}
5 changes: 5 additions & 0 deletions apps/web/lib/campus.ts
Original file line number Diff line number Diff line change
@@ -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")
Expand Down

0 comments on commit 7ed43a4

Please sign in to comment.