fix: sitemap 加 force-dynamic + try-catch(构建时不查数据库)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import type { MetadataRoute } from "next";
|
||||
import { getPublishedPosts, getPublicCategories, getAllTags } from "@/lib/store";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || "https://asui.xyz";
|
||||
|
||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
@@ -12,6 +14,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
{ url: `${SITE_URL}/about`, changeFrequency: "yearly", priority: 0.5 },
|
||||
];
|
||||
|
||||
try {
|
||||
const [publishedPosts, tags, categories] = await Promise.all([
|
||||
getPublishedPosts(),
|
||||
getAllTags(),
|
||||
@@ -40,4 +43,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
}));
|
||||
|
||||
return [...staticRoutes, ...postRoutes, ...tagRoutes, ...categoryRoutes];
|
||||
} catch {
|
||||
return staticRoutes;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user