From 1d5242eef366a79a06d68825f7d71aa51557df61 Mon Sep 17 00:00:00 2001 From: Michael Novotny Date: Tue, 1 Aug 2023 20:34:45 -0500 Subject: [PATCH] Adds better sitemap error handling (#1134) * Adds better sitemap error handling * Removes extra `flat` --------- Co-authored-by: Lee Robinson --- app/sitemap.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/sitemap.ts b/app/sitemap.ts index d8cdfd2ea..46d39669c 100644 --- a/app/sitemap.ts +++ b/app/sitemap.ts @@ -1,11 +1,16 @@ import { getCollections, getPages, getProducts } from 'lib/shopify'; import { MetadataRoute } from 'next'; +type Route = { + url: string; + lastModified: string; +}; + const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL ? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}` : 'http://localhost:3000'; -export default async function sitemap(): Promise>> { +export default async function sitemap(): Promise { const routesMap = [''].map((route) => ({ url: `${baseUrl}${route}`, lastModified: new Date().toISOString() @@ -32,9 +37,13 @@ export default async function sitemap(): Promise