Skip to content

Commit

Permalink
Adds sitemap generation for main pages and contributor profiles (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Jul 10, 2024
1 parent 34067f6 commit 7540892
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ data-repo

# Package Lock
package-lock.json
yarn.lock
yarn.lock

# Files placed by data-repo
/public/logo.png
15 changes: 15 additions & 0 deletions app/contributors/sitemap.ts
Original file line number Diff line number Diff line change
@@ -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<MetadataRoute.Sitemap> {
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,
}),
);
}
29 changes: 29 additions & 0 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { env } from "@/env.mjs";
import { MetadataRoute } from "next";

export const sitemapEntry = (
path: string,
attrs: Omit<MetadataRoute.Sitemap[number], "url"> = {},
): 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 }),
];
}

0 comments on commit 7540892

Please sign in to comment.