From 75408921c61c781a1525b8ffb2089fba21ffde8d Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Wed, 10 Jul 2024 18:16:25 +0530 Subject: [PATCH] Adds sitemap generation for main pages and contributor profiles (#462) --- .gitignore | 5 ++++- app/contributors/sitemap.ts | 15 +++++++++++++++ app/sitemap.ts | 29 +++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 app/contributors/sitemap.ts create mode 100644 app/sitemap.ts diff --git a/.gitignore b/.gitignore index 24103bb9..a967a68a 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,7 @@ data-repo # Package Lock package-lock.json -yarn.lock \ No newline at end of file +yarn.lock + +# Files placed by data-repo +/public/logo.png \ No newline at end of file diff --git a/app/contributors/sitemap.ts b/app/contributors/sitemap.ts new file mode 100644 index 00000000..80ff7024 --- /dev/null +++ b/app/contributors/sitemap.ts @@ -0,0 +1,15 @@ +import { sitemapEntry } from "@/app/sitemap"; +import { getContributors, getContributorsSlugs } from "@/lib/api"; +import { MetadataRoute } from "next"; + +export default async function sitemap(): Promise { + const contriutors = await getContributors(); + return contriutors.map((contributor) => + sitemapEntry(`/contributors/${contributor.github}`, { + lastModified: contributor.activityData.last_updated + ? new Date(contributor.activityData.last_updated) + : undefined, + priority: 0.8, + }), + ); +} diff --git a/app/sitemap.ts b/app/sitemap.ts new file mode 100644 index 00000000..dd801617 --- /dev/null +++ b/app/sitemap.ts @@ -0,0 +1,29 @@ +import { env } from "@/env.mjs"; +import { MetadataRoute } from "next"; + +export const sitemapEntry = ( + path: string, + attrs: Omit = {}, +): MetadataRoute.Sitemap[number] => { + return { + changeFrequency: "daily", + lastModified: new Date(), + priority: 1, + ...attrs, + url: `${env.NEXT_PUBLIC_META_URL}${path}`, + }; +}; + +const entry = sitemapEntry; + +export default function sitemap(): MetadataRoute.Sitemap { + return [ + entry("/"), + entry("/people"), + entry("/projects"), + entry("/releases"), + entry("/leaderboard"), + entry("/issues"), + entry("/feed", { changeFrequency: "always", priority: 0.7 }), + ]; +}