Articles: force-dynamic + notFound for deleted posts (no stale ISR)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { Metadata } from "next";
|
||||
import { cleanExcerpt } from "@/lib/articles/excerpt";
|
||||
import { redirect } from "next/navigation";
|
||||
import { notFound } from "next/navigation";
|
||||
import ArticleDetailPage from "./ArticleDetailClient";
|
||||
import type { Article } from "@/lib/articles/types";
|
||||
import {
|
||||
@@ -10,7 +10,10 @@ import {
|
||||
getRelatedForumThreads, type RelatedForumThread,
|
||||
} from "@/lib/articles/legacy-source";
|
||||
|
||||
export const revalidate = 3600;
|
||||
// Deleted or unpublished posts must 404 immediately — never serve a stale
|
||||
// cached article shell for up to an hour after DB removal.
|
||||
export const dynamic = "force-dynamic";
|
||||
export const revalidate = 0;
|
||||
export const dynamicParams = true;
|
||||
|
||||
interface PageProps {
|
||||
@@ -90,9 +93,7 @@ export default async function ArticlePage({ params }: PageProps) {
|
||||
const { slug } = await params;
|
||||
const { article, related, relatedForumThreads } = await loadArticle(slug);
|
||||
if (!article) {
|
||||
// Slug isn't in any of our article tables — send the reader to the news
|
||||
// index so a click from the homepage/ticker doesn't dead-end on 404.
|
||||
redirect("/news");
|
||||
notFound();
|
||||
}
|
||||
|
||||
const articleSchema = {
|
||||
|
||||
Reference in New Issue
Block a user