Merged in fix/sitemap-route (pull request #1801)
Fix: sitemap - now the route works * Fix: sitemap - now the route works Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -17,6 +17,9 @@ export async function GET(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sitemapId = context.params.sitemapId
|
const sitemapId = context.params.sitemapId
|
||||||
|
|
||||||
|
console.log("[SITEMAP] Fetching sitemap by ID", sitemapId)
|
||||||
|
|
||||||
if (!sitemapId) {
|
if (!sitemapId) {
|
||||||
notFound()
|
notFound()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,18 @@ export async function GET() {
|
|||||||
notFound()
|
notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`[SITEMAP] Fetching sitemap`)
|
||||||
|
|
||||||
const lastUpdated = await getLastUpdated()
|
const lastUpdated = await getLastUpdated()
|
||||||
|
|
||||||
const sitemaps = await getSitemapIds()
|
const sitemaps = await getSitemapIds()
|
||||||
|
|
||||||
|
if (!sitemaps || sitemaps.length === 0) {
|
||||||
|
return new Response("No sitemaps found", { status: 404 })
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[SITEMAP] Sitemaps retrieved: ${sitemaps.length}`)
|
||||||
|
|
||||||
const urls = sitemaps.map(
|
const urls = sitemaps.map(
|
||||||
(id) => `<sitemap>
|
(id) => `<sitemap>
|
||||||
<loc>${env.PUBLIC_URL}/sitemap-${id}.xml</loc>
|
<loc>${env.PUBLIC_URL}/sitemap-${id}.xml</loc>
|
||||||
|
|||||||
@@ -125,5 +125,5 @@ export const config = {
|
|||||||
* public routes inside middleware.
|
* public routes inside middleware.
|
||||||
* (https://clerk.com/docs/quickstarts/nextjs?utm_source=sponsorship&utm_medium=youtube&utm_campaign=code-with-antonio&utm_content=12-31-2023#add-authentication-to-your-app)
|
* (https://clerk.com/docs/quickstarts/nextjs?utm_source=sponsorship&utm_medium=youtube&utm_campaign=code-with-antonio&utm_content=12-31-2023#add-authentication-to-your-app)
|
||||||
*/
|
*/
|
||||||
matcher: ["/((?!.+\\.[\\w]+$|_next|_static|.netlify|api|trpc).*)"],
|
matcher: ["/((?!.+\\.[\\w]+$|_next|_static|.netlify|api|trpc|sitemap).*)"],
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user