-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package not working with Next.js 15 (Async Request APIs) #895
Comments
Personally I just use nextjs native sitemap feature nowadays since this library is not maintained anymore. |
@iamvishnusankar any updates from you? It would be so nice if you implement nextjs15 support into this package |
Next sitemap doesn't allow for sitemap index generation and I've had problems creating 'force-dynamic' sitemaps, sitemap.ts doesn't seem to respect export const dynamic... I've written my own mini version of this lib if any one wants to copy paste. import { NextResponse } from "next/server";
export function buildSitemapIndex(sitemaps: string[]) {
let xml = '<?xml version="1.0" encoding="UTF-8"?>';
xml += '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
for (const sitemapURL of sitemaps) {
xml += "<sitemap>";
xml += "<loc>";
xml += sitemapURL;
xml += "</loc>";
xml += "</sitemap>";
}
xml += "</sitemapindex>";
return new NextResponse(xml, {
headers: {
"Content-Type": "application/xml",
"Content-Length": Buffer.byteLength(xml).toString(),
},
});
}
type TSitemapEntry = {
priority?: number;
loc: string;
changefreq?:
| "always"
| "hourly"
| "daily"
| "weekly"
| "monthly"
| "yearly"
| "never";
lastmod?: Date;
};
export function buildSitemap(items: TSitemapEntry[]) {
let xml = '<?xml version="1.0" encoding="UTF-8"?>';
xml += `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">`;
for (const item of items) {
xml += "<url>";
xml += "<loc>" + item.loc + "</loc>";
if (item.lastmod) {
xml += "<lastmod>";
xml += item.lastmod.toISOString();
xml += "</lastmod>";
}
if (item.changefreq) {
xml += "<changefreq>";
xml += item.changefreq;
xml += "</changefreq>";
}
if (item.priority) {
xml += "<priority>";
xml += item.priority;
xml += "</priority>";
}
xml += "</url>";
}
xml += "</urlset>";
return new NextResponse(xml, {
headers: {
"Content-Type": "application/xml",
"Content-Length": Buffer.byteLength(xml).toString(),
},
});
} ibn4 template literals are the same speed as concatenation... |
Hi,
I just upgraded Next.js to v15, and the
next-sitemap
package stopped working. The request API is now async, which seems to disrupt the sitemap generation functionality.Has anyone managed to get sitemaps working with Next 15?
Thanks!
The text was updated successfully, but these errors were encountered: