Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/api/admin/impact-stories/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions app/api/admin/impact-stories/route.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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),
Expand Down
5 changes: 5 additions & 0 deletions app/api/admin/projects/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions app/api/admin/projects/route.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(),
Expand Down
5 changes: 5 additions & 0 deletions app/api/admin/testimonials/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions app/api/admin/testimonials/route.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(),
Expand Down
4 changes: 3 additions & 1 deletion app/projects/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProjectItem[]> {
try {
Expand Down
4 changes: 3 additions & 1 deletion app/testimonials/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
Loading