Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

Make the sitemap.xml use the database for good SEO (#1334)

Sean Boult3c74e03bc817
diff --git a/apps/web/src/app/sitemap.ts b/apps/web/src/app/sitemap.ts
index 5744ad9d..83cb29d1 100644
--- a/apps/web/src/app/sitemap.ts
+++ b/apps/web/src/app/sitemap.ts
@@ -1,37 +1,35 @@
import type { MetadataRoute } from 'next';
+import { prisma } from '@repo/db';
const URL = 'https://typehero.dev';
-export default function sitemap(): MetadataRoute.Sitemap {
+
+export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
+ const allChallenges = await prisma.challenge.findMany();
+
return [
{
url: `${URL}/`,
lastModified: new Date(),
- changeFrequency: 'monthly',
- priority: 1,
},
{
url: `${URL}/explore`,
lastModified: new Date(),
- changeFrequency: 'weekly',
- priority: 0.8,
},
{
url: `${URL}/tracks`,
lastModified: new Date(),
- changeFrequency: 'weekly',
- priority: 0.5,
},
{
url: `${URL}/tos`,
lastModified: new Date(),
- changeFrequency: 'yearly',
- priority: 0.5,
},
{
url: `${URL}/privacy`,
lastModified: new Date(),
- changeFrequency: 'yearly',
- priority: 0.5,
},
+ ...allChallenges.map((challenge) => ({
+ url: `${URL}/challenges/${challenge.slug}`,
+ lastModified: new Date(challenge.updatedAt),
+ })),
];
}