Fix the sitemap indexes
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { getAllBlogs } from "@/content/blogs/blogs";
|
||||
import { getSettings } from "@/content/settings/settings";
|
||||
import type { APIRoute } from "astro";
|
||||
import minifyXML from "minify-xml";
|
||||
@@ -13,9 +14,25 @@ export const GET = (async () => {
|
||||
];
|
||||
|
||||
if (settings.blog.enabled) {
|
||||
const blogLastModifieds = [
|
||||
settings.blog.lastModified,
|
||||
settings.sitemap.lastModified,
|
||||
settings.website.lastModified
|
||||
];
|
||||
|
||||
let blogs = await getAllBlogs(settings);
|
||||
|
||||
blogs.forEach((blog) => {
|
||||
blogLastModifieds.push(blog.lastModified);
|
||||
});
|
||||
|
||||
const lastModifiedBlogs = blogLastModifieds.sort((a: Date, b: Date) => {
|
||||
return b.getTime() - a.getTime();
|
||||
});
|
||||
|
||||
sitemapIndex.push({
|
||||
url: "/sitemap/blogs.xml",
|
||||
lastModified: new Date()
|
||||
lastModified: lastModifiedBlogs[0]
|
||||
});
|
||||
};
|
||||
if (settings.project.enabled) {
|
||||
|
||||
Reference in New Issue
Block a user