diff --git a/app/api/admin/impact-stories/[id]/route.ts b/app/api/admin/impact-stories/[id]/route.ts index aa6b1df..4894d24 100644 --- a/app/api/admin/impact-stories/[id]/route.ts +++ b/app/api/admin/impact-stories/[id]/route.ts @@ -1,4 +1,5 @@ import { NextResponse } from 'next/server'; +import { revalidatePath } from 'next/cache'; import { cookies } from 'next/headers'; import { verify } from 'jsonwebtoken'; import { ReadonlyRequestCookies } from 'next/dist/server/web/spec-extension/adapters/request-cookies'; @@ -76,6 +77,8 @@ export async function PATCH(request: Request, { params }: { params: Promise<{ id } await connectDB(); + // The public page is cached; refresh it now so the change shows at once + revalidatePath('/testimonials'); await ActivityLog.create({ entityType: 'ImpactStory', entityId: String(story._id), @@ -107,6 +110,8 @@ export async function DELETE(request: Request, { params }: { params: Promise<{ i } await connectDB(); + // The public page is cached; refresh it now so the change shows at once + revalidatePath('/testimonials'); await ActivityLog.create({ entityType: 'ImpactStory', entityId: id, diff --git a/app/api/admin/impact-stories/route.ts b/app/api/admin/impact-stories/route.ts index a9e3f2a..02f1370 100644 --- a/app/api/admin/impact-stories/route.ts +++ b/app/api/admin/impact-stories/route.ts @@ -1,4 +1,5 @@ import { NextResponse } from 'next/server'; +import { revalidatePath } from 'next/cache'; import { cookies } from 'next/headers'; import { verify } from 'jsonwebtoken'; import { ReadonlyRequestCookies } from 'next/dist/server/web/spec-extension/adapters/request-cookies'; @@ -69,6 +70,8 @@ export async function POST(request: Request) { }); await connectDB(); + // The public page is cached; refresh it now so the change shows at once + revalidatePath('/testimonials'); await ActivityLog.create({ entityType: 'ImpactStory', entityId: String(story._id), diff --git a/app/api/admin/projects/[id]/route.ts b/app/api/admin/projects/[id]/route.ts index 43626e9..ae861b0 100644 --- a/app/api/admin/projects/[id]/route.ts +++ b/app/api/admin/projects/[id]/route.ts @@ -1,4 +1,5 @@ import { NextResponse } from 'next/server'; +import { revalidatePath } from 'next/cache'; import connectDB from '@/lib/db'; import { Project } from '@/models/Project'; import { ActivityLog } from '@/models/ActivityLog'; @@ -51,6 +52,8 @@ export async function PATCH( } // Log activity + // The public page is cached; refresh it now so the change shows at once + revalidatePath('/projects'); await ActivityLog.create({ entityType: 'Project', entityId: project._id.toString(), @@ -93,6 +96,8 @@ export async function DELETE( } // Log activity + // The public page is cached; refresh it now so the change shows at once + revalidatePath('/projects'); await ActivityLog.create({ entityType: 'Project', entityId: id, diff --git a/app/api/admin/projects/route.ts b/app/api/admin/projects/route.ts index b6c74a9..d658bc5 100644 --- a/app/api/admin/projects/route.ts +++ b/app/api/admin/projects/route.ts @@ -1,4 +1,5 @@ import { NextResponse } from 'next/server'; +import { revalidatePath } from 'next/cache'; import connectDB from '@/lib/db'; import { Project } from '@/models/Project'; import { ActivityLog } from '@/models/ActivityLog'; @@ -65,6 +66,8 @@ export async function POST(request: Request) { }); // Log activity + // The public page is cached; refresh it now so the change shows at once + revalidatePath('/projects'); await ActivityLog.create({ entityType: 'Project', entityId: project._id.toString(), diff --git a/app/api/admin/testimonials/[id]/route.ts b/app/api/admin/testimonials/[id]/route.ts index a66f1dc..a182394 100644 --- a/app/api/admin/testimonials/[id]/route.ts +++ b/app/api/admin/testimonials/[id]/route.ts @@ -1,4 +1,5 @@ import { NextResponse } from 'next/server'; +import { revalidatePath } from 'next/cache'; import connectDB from '@/lib/db'; import { Testimonial } from '@/models/Testimonial'; import { ActivityLog } from '@/models/ActivityLog'; @@ -51,6 +52,8 @@ export async function PATCH( } // Log activity + // The public page is cached; refresh it now so the change shows at once + revalidatePath('/testimonials'); await ActivityLog.create({ entityType: 'Testimonial', entityId: testimonial._id.toString(), @@ -93,6 +96,8 @@ export async function DELETE( } // Log activity + // The public page is cached; refresh it now so the change shows at once + revalidatePath('/testimonials'); await ActivityLog.create({ entityType: 'Testimonial', entityId: id, diff --git a/app/api/admin/testimonials/route.ts b/app/api/admin/testimonials/route.ts index ad4bf1f..d52d458 100644 --- a/app/api/admin/testimonials/route.ts +++ b/app/api/admin/testimonials/route.ts @@ -1,4 +1,5 @@ import { NextResponse } from 'next/server'; +import { revalidatePath } from 'next/cache'; import connectDB from '@/lib/db'; import { Testimonial } from '@/models/Testimonial'; import { ActivityLog } from '@/models/ActivityLog'; @@ -62,6 +63,8 @@ export async function POST(request: Request) { }); // Log activity + // The public page is cached; refresh it now so the change shows at once + revalidatePath('/testimonials'); await ActivityLog.create({ entityType: 'Testimonial', entityId: testimonial._id.toString(), diff --git a/app/projects/page.tsx b/app/projects/page.tsx index fdc1fd7..59c4449 100644 --- a/app/projects/page.tsx +++ b/app/projects/page.tsx @@ -5,7 +5,9 @@ import { ProjectTile, type ProjectItem } from '@/components/projects/project-til import { Card, Eyebrow, PageHero, Panel, Section } from '@/components/site/page-kit'; import { withSocial } from "@/lib/seo"; -export const dynamic = 'force-dynamic'; +// Served from cache and rebuilt at most every five minutes. Admin changes to +// approved projects refresh it straight away through revalidatePath. +export const revalidate = 300; async function getProjects(): Promise { try { diff --git a/app/testimonials/page.tsx b/app/testimonials/page.tsx index 68ff689..231709a 100644 --- a/app/testimonials/page.tsx +++ b/app/testimonials/page.tsx @@ -6,7 +6,9 @@ import type { Testimonial } from '@/components/testimonial-card'; import { Card, Eyebrow, PageHero, Panel, Section } from '@/components/site/page-kit'; import { withSocial } from "@/lib/seo"; -export const dynamic = 'force-dynamic'; +// Served from cache and rebuilt at most every five minutes. Admin changes to +// approved stories refresh it straight away through revalidatePath. +export const revalidate = 300; export const metadata = withSocial({ alternates: { canonical: "/testimonials" },