fix: add change log routes to the sitemap
This commit is contained in:
parent
dc11ef8aef
commit
da4973954e
1 changed files with 13 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
import { getAllBlogPostSlugs } from "@/lib/getBlogPost";
|
import { getAllBlogPostSlugs } from "@/lib/getBlogPost";
|
||||||
|
import clientPromise from "@/lib/db";
|
||||||
|
|
||||||
export default async function sitemap() {
|
export default async function sitemap() {
|
||||||
const blogPostSlugs = await getAllBlogPostSlugs();
|
const blogPostSlugs = await getAllBlogPostSlugs();
|
||||||
|
@ -25,5 +26,16 @@ export default async function sitemap() {
|
||||||
lastModified: new Date().toISOString().split("T")[0]
|
lastModified: new Date().toISOString().split("T")[0]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return [...baseRoutes, ...blogRoutes];
|
let changelogRoutes = [];
|
||||||
|
try {
|
||||||
|
const client = await clientPromise;
|
||||||
|
const db = client.db(process.env.MONGODB_DB);
|
||||||
|
const slugs = await db.collection("pages").find().toArray();
|
||||||
|
changelogRoutes = slugs.map((slug) => ({
|
||||||
|
url: `https://svrjs.vercel.app/changelog/${slug.slug}`,
|
||||||
|
lastModified: new Date().toISOString().split("T")[0]
|
||||||
|
}));
|
||||||
|
} catch (err) {}
|
||||||
|
|
||||||
|
return [...baseRoutes, ...blogRoutes, ...changelogRoutes];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue