️ perf(build): remove sitemap generation to cut static export time (#15702)

* ️ perf(build): remove sitemap generation to cut static export time

The sitemap accounted for 772 of 827 prerendered pages, each fetching
marketplace data at build time. Static generation drops from 28.2s to
0.3s and total next build from ~59s to ~32s.

* Redirect legacy sitemap URLs to the landing site

* Redirect sitemap index to landing sitemap
This commit is contained in:
Innei
2026-06-12 15:17:52 +08:00
committed by GitHub
parent 7633c0e83f
commit 365dd1ff64
9 changed files with 10 additions and 845 deletions
-31
View File
@@ -1,31 +0,0 @@
import { writeFileSync } from 'node:fs';
import path from 'node:path';
import dotenv from 'dotenv';
import { RedisKeyNamespace, resetPrefixedRedisClient } from '@/libs/redis';
import { Sitemap } from '@/server/sitemap';
dotenv.config();
const genSitemap = async () => {
const sitemapModule = new Sitemap();
const sitemapIndexXML = await sitemapModule.getIndex();
const filename = path.resolve(__dirname, '../../', 'public', 'sitemap-index.xml');
writeFileSync(filename, sitemapIndexXML);
};
const main = async () => {
try {
await genSitemap();
} finally {
console.log('[build-sitemap] Closing LobeHub Redis client');
await resetPrefixedRedisClient(RedisKeyNamespace.LOBEHUB);
console.log('[build-sitemap] Closed LobeHub Redis client');
}
};
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});