Skip to content

Commit

Permalink
Fix sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
gnovl committed Oct 26, 2024
1 parent 9ff527d commit 3ffbec1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions next-sitemap.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: process.env.SITE_URL || "https://averiashogar.es",
siteUrl: process.env.NEXT_WEBSITE_URL || "https://averiashogar.es",
generateRobotsTxt: true,
sitemapSize: 7000,
changefreq: "daily",
Expand All @@ -14,6 +14,6 @@ module.exports = {
allow: "/",
},
],
additionalSitemaps: ["https://averiashogar.es/server-sitemap.xml"],
additionalSitemaps: [`${process.env.NEXT_WEBSITE_URL}/server-sitemap.xml`],
},
};
9 changes: 6 additions & 3 deletions src/app/server-sitemap.xml/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ export async function GET(request: Request) {
const fields: ISitemapField[] = files
.filter((filename) => filename.endsWith(".mdx"))
.map((filename) => ({
loc: `${process.env.SITE_URL}/blog/${filename.replace(".mdx", "")}`,
loc: `${process.env.NEXT_WEBSITE_URL}/blog/${filename.replace(
".mdx",
""
)}`,
lastmod: new Date().toISOString(),
changefreq: "daily" as const, // This fixes the TypeScript error
priority: 0.7,
}));

// Add the main blog page
// Add the main blog page to the sitemap
fields.push({
loc: `${process.env.SITE_URL}/blog`,
loc: `${process.env.NEXT_WEBSITE_URL}/blog`,
lastmod: new Date().toISOString(),
changefreq: "daily" as const, // This fixes the TypeScript error
priority: 0.8,
Expand Down

0 comments on commit 3ffbec1

Please sign in to comment.