From 89f8d6e223b755497b4c335f8f2c1207aaf6bb44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E6=97=AD?= <> Date: Wed, 24 Jun 2026 17:14:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=80=E6=9C=89=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=8A=A0=20force-dynamic=EF=BC=88=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E6=9E=84=E5=BB=BA=E6=97=B6=E9=A2=84=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E7=A9=BA=E6=95=B0=E6=8D=AE=E7=BC=93=E5=AD=98=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 构建时数据库为空,Next.js 缓存了空页面。 加 force-dynamic 强制每次请求时从数据库读取。 --- src/app/blog/page.tsx | 2 ++ src/app/categories/page.tsx | 2 ++ src/app/page.tsx | 2 ++ src/app/posts/[slug]/page.tsx | 5 +---- src/app/tags/page.tsx | 2 ++ 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/blog/page.tsx b/src/app/blog/page.tsx index e761fe3..731f90b 100644 --- a/src/app/blog/page.tsx +++ b/src/app/blog/page.tsx @@ -2,6 +2,8 @@ import { Suspense } from "react"; import { getPublishedPosts } from "@/lib/store"; import BlogList from "@/components/BlogList"; +export const dynamic = "force-dynamic"; + export const metadata = { title: "文章", description: "胡旭的博客文章 — 技术、随笔、旅行、阅读", diff --git a/src/app/categories/page.tsx b/src/app/categories/page.tsx index 82a45f7..9232dbc 100644 --- a/src/app/categories/page.tsx +++ b/src/app/categories/page.tsx @@ -2,6 +2,8 @@ import Link from "next/link"; import { getPublicCategories, getPostsByCategory } from "@/lib/store"; import GsapReveal from "@/components/GsapReveal"; +export const dynamic = "force-dynamic"; + export const metadata = { title: "分类", description: "按分类浏览博客文章", diff --git a/src/app/page.tsx b/src/app/page.tsx index 0cac170..d59b64d 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -2,6 +2,8 @@ import { getPublishedPosts } from "@/lib/store"; import HeroSection from "@/components/HeroSection"; import { FeaturedGrid, RecentList } from "@/components/PostSections"; +export const dynamic = "force-dynamic"; + export default async function HomePage() { const posts = await getPublishedPosts(); const featuredPosts = posts.filter((p) => p.featured); diff --git a/src/app/posts/[slug]/page.tsx b/src/app/posts/[slug]/page.tsx index efc43af..1c370fc 100644 --- a/src/app/posts/[slug]/page.tsx +++ b/src/app/posts/[slug]/page.tsx @@ -5,10 +5,7 @@ import PostContent from "@/components/PostContent"; const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || "https://asui.xyz"; -export async function generateStaticParams() { - const posts = await getPublishedPosts(); - return posts.map((post) => ({ slug: post.slug })); -} +export const dynamic = "force-dynamic"; export async function generateMetadata({ params, diff --git a/src/app/tags/page.tsx b/src/app/tags/page.tsx index ec58ffe..8ea31cb 100644 --- a/src/app/tags/page.tsx +++ b/src/app/tags/page.tsx @@ -1,6 +1,8 @@ import { getAllTags } from "@/lib/store"; import GsapReveal from "@/components/GsapReveal"; +export const dynamic = "force-dynamic"; + export const metadata = { title: "标签", description: "按标签浏览博客文章",