From 43bb3349cb3cc8c8b8eeffd8a9c25e2aca0f5bb4 Mon Sep 17 00:00:00 2001 From: Vishakh Date: Thu, 7 May 2026 16:39:10 -0400 Subject: [PATCH] Rationalized sitemap. --- app/sitemap.ts | 58 +++++++------------------------------------------- next-env.d.ts | 2 +- 2 files changed, 9 insertions(+), 51 deletions(-) diff --git a/app/sitemap.ts b/app/sitemap.ts index 27d4454..71abda4 100644 --- a/app/sitemap.ts +++ b/app/sitemap.ts @@ -1,55 +1,13 @@ import { MetadataRoute } from 'next'; -import { executeQuerySingle, executeQuery } from '@/lib/db'; const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || 'https://explorer.monadicdna.com'; -const BATCH_SIZE = 10_000; -// generateSitemaps splits the study pages across multiple sitemap files, -// each with up to BATCH_SIZE URLs, staying within the 50K-per-file limit. -export async function generateSitemaps() { - try { - const row = await executeQuerySingle<{ max_id: number }>( - 'SELECT MAX(id) AS max_id FROM gwas_catalog', - [] - ); - const maxId = row?.max_id ?? 1000; - const count = Math.ceil(maxId / BATCH_SIZE); - // id 0 is reserved for static pages; ids 1..n are study batches - return Array.from({ length: count + 1 }, (_, i) => ({ id: i })); - } catch { - return [{ id: 0 }]; - } -} - -export default async function sitemap({ id }: { id: number }): Promise { - // id === 0: static pages only - if (id === 0) { - return [ - { url: SITE_URL, lastModified: new Date(), changeFrequency: 'weekly', priority: 1.0 }, - { url: `${SITE_URL}/explore`, lastModified: new Date(), changeFrequency: 'daily', priority: 0.9 }, - { url: `${SITE_URL}/dna-chat`, lastModified: new Date(), changeFrequency: 'weekly', priority: 0.8 }, - { url: `${SITE_URL}/overview-report`, lastModified: new Date(), changeFrequency: 'weekly', priority: 0.8 }, - { url: `${SITE_URL}/subscribe`, lastModified: new Date(), changeFrequency: 'weekly', priority: 0.7 }, - ]; - } - - // ids 1..n: study pages in BATCH_SIZE chunks - const batchIndex = id - 1; - const minId = batchIndex * BATCH_SIZE + 1; - const maxId = (batchIndex + 1) * BATCH_SIZE; - - try { - const rows = await executeQuery<{ id: number }>( - 'SELECT id FROM gwas_catalog WHERE id BETWEEN $1 AND $2 ORDER BY id', - [minId, maxId] - ); - return rows.map(row => ({ - url: `${SITE_URL}/study/${row.id}`, - lastModified: new Date(), - changeFrequency: 'monthly', - priority: 0.6, - })); - } catch { - return []; - } +export default function sitemap(): MetadataRoute.Sitemap { + return [ + { url: SITE_URL, lastModified: new Date(), changeFrequency: 'weekly', priority: 1.0 }, + { url: `${SITE_URL}/explore`, lastModified: new Date(), changeFrequency: 'daily', priority: 0.9 }, + { url: `${SITE_URL}/dna-chat`, lastModified: new Date(), changeFrequency: 'weekly', priority: 0.8 }, + { url: `${SITE_URL}/overview-report`, lastModified: new Date(), changeFrequency: 'weekly', priority: 0.8 }, + { url: `${SITE_URL}/subscribe`, lastModified: new Date(), changeFrequency: 'weekly', priority: 0.7 }, + ]; } diff --git a/next-env.d.ts b/next-env.d.ts index c4b7818..9edff1c 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,6 +1,6 @@ /// /// -import "./.next/dev/types/routes.d.ts"; +import "./.next/types/routes.d.ts"; // NOTE: This file should not be edited // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.