mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-14 03:30:19 +00:00
⚡️ 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:
@@ -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;
|
||||
});
|
||||
Reference in New Issue
Block a user