update sitemap

This commit is contained in:
MuslemRahimi 2025-02-09 15:02:12 +01:00
parent 1895a37b3e
commit 7784d8eb7b

View File

@ -96,8 +96,12 @@ export async function GET({ locals }) {
const articles = await pb.collection("articles").getFullList({
sort: "-created",
});
const tutorials = await pb.collection("tutorials").getFullList({
sort: "-created",
});
const body = sitemap(stocks, articles, pages);
const body = sitemap(stocks, articles, pages, tutorials);
const response = new Response(body);
response.headers.set("Cache-Control", "max-age=0, s-maxage=3600");
response.headers.set("Content-Type", "application/xml");
@ -109,6 +113,7 @@ const sitemap = (
stocks,
articles,
pages,
tutorials,
) => `<?xml version="1.0" encoding="UTF-8" ?>
<urlset
xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"
@ -136,6 +141,15 @@ const sitemap = (
`,
)
.join("")}
${tutorials
.map(
(item) => `
<url>
<loc>${website}/learning-center/article/${convertToSlug(item?.title)}</loc>
</url>
`,
)
.join("")}
${stocks
.map((ticker) => {
// Determine the path based on the type of the ticker