Skip to content

Commit

Permalink
feat: add sitemap file
Browse files Browse the repository at this point in the history
  • Loading branch information
rikhall1515 committed Apr 19, 2024
1 parent 0963885 commit d48bb83
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { MetadataRoute } from "next";

import { BASE_PATH, BASE_URL } from "@/next.constants.mjs";

// This is the combination of the Application Base URL and Base PATH
const baseUrlAndPath = `${BASE_URL}${BASE_PATH}`;

// This allows us to generate a `sitemap.xml` file dynamically based on the needs of the Node.js Website
// Next.js Sitemap Generation doesn't support `alternate` refs yet
// @see https://github.com/vercel/next.js/discussions/55646
const sitemap = async (): Promise<MetadataRoute.Sitemap> => {
const staticUrls = [
"",
"legal/terms",
"legal/support-terms",
"legal/sla",
"legal/privacy-policy",
"sign-in",
"sign-up",
"about",
"help",
];
const currentDate = new Date().toISOString();

return [...staticUrls].map((route) => ({
url: `${baseUrlAndPath}${route}`,
lastModified: currentDate,
changeFrequency: "always",
}));
};

export default sitemap;

// Enforces that this route is used as static rendering
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamic
export const dynamic = "error";

0 comments on commit d48bb83

Please sign in to comment.