From e88842f4d00e8056094517ccaa890febec1c0b94 Mon Sep 17 00:00:00 2001 From: Sherakama Date: Tue, 2 Apr 2024 15:47:41 -0700 Subject: [PATCH 1/2] Update sitemap.ts full url in sitemap --- app/sitemap.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/sitemap.ts b/app/sitemap.ts index f6af812b..91b2b767 100644 --- a/app/sitemap.ts +++ b/app/sitemap.ts @@ -21,10 +21,11 @@ export default async function sitemap(): Promise { // Exclude any stories with noindex set to true on Storyblok const indexStories = response.filter((story) => !story.content?.noindex); - + const currentURL = process.env.URL || process.env.DEPLOY_PRIME_URL || 'https://momentum.stanford.edu'; + const ret = indexStories.map((story) => { return { - url: story.path ?? `/${story.full_slug}`, + url: story.path ? `${currentURL}/${story.path}` : `${currentURL}/${story.full_slug}`, lastModified: new Date(story.published_at), changeFrequency: 'daily', // Added in 13.4.5 priority: 0.5, // Added in 13.4.5 From 5157a4433e5624f7f8bc6bde2eff9a778693096e Mon Sep 17 00:00:00 2001 From: Sherakama Date: Wed, 3 Apr 2024 09:08:44 -0700 Subject: [PATCH 2/2] Right trim slash --- app/sitemap.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/sitemap.ts b/app/sitemap.ts index 91b2b767..0221f004 100644 --- a/app/sitemap.ts +++ b/app/sitemap.ts @@ -24,8 +24,9 @@ export default async function sitemap(): Promise { const currentURL = process.env.URL || process.env.DEPLOY_PRIME_URL || 'https://momentum.stanford.edu'; const ret = indexStories.map((story) => { + const url = story.path ? `${currentURL}/${story.path}` : `${currentURL}/${story.full_slug}`; return { - url: story.path ? `${currentURL}/${story.path}` : `${currentURL}/${story.full_slug}`, + url: url.replace(/\/+$/, ''), lastModified: new Date(story.published_at), changeFrequency: 'daily', // Added in 13.4.5 priority: 0.5, // Added in 13.4.5