Skip to content

Commit ecf4953

Browse files
committed
fix(archive): prevent prerendering for admin pages and use Next.js Image
- Add dynamic = 'force-dynamic' to all admin archive pages - Replace <img> tags with Next.js <Image> component - Fix build errors in CI environment - Ensures pages don't try to connect to DB during static generation
1 parent e303e5e commit ecf4953

File tree

10 files changed

+28
-2
lines changed

10 files changed

+28
-2
lines changed

src/app/admin/archive/[year]/content/add/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { useRouter, useParams, useSearchParams } from "next/navigation";
55
import { toast } from "sonner";
66
import Link from "next/link";
77

8+
export const dynamic = 'force-dynamic';
9+
810
interface Category {
911
id: string;
1012
name: string;

src/app/admin/archive/[year]/edit/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { useState, useEffect } from "react";
44
import { useRouter, useParams } from "next/navigation";
55
import { toast } from "sonner";
66
import Link from "next/link";
7+
import Image from "next/image";
8+
9+
export const dynamic = 'force-dynamic';
710

811
export default function EditArchiveYearPage() {
912
const router = useRouter();
@@ -194,7 +197,9 @@ export default function EditArchiveYearPage() {
194197
{coverImageUrl && (
195198
<div className="mt-2">
196199
<p className="text-sm text-green-600">Current image: {coverImageUrl}</p>
197-
<img src={coverImageUrl} alt="Cover preview" className="mt-2 w-32 h-32 object-cover rounded" />
200+
<div className="relative w-32 h-32 mt-2">
201+
<Image src={coverImageUrl} alt="Cover preview" fill className="object-cover rounded" />
202+
</div>
198203
</div>
199204
)}
200205
<p className="text-xs text-muted-foreground mt-1">

src/app/admin/archive/[year]/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { db, archiveYears, archiveCategories, archivePapers } from "@/db/schema"
33
import { eq } from "drizzle-orm";
44
import { notFound } from "next/navigation";
55

6+
export const dynamic = 'force-dynamic';
7+
68
export default async function AdminArchiveYearPage({ params }: { params: Promise<{ year: string }> }) {
79
const { year: yearStr } = await params;
810
const year = parseInt(yearStr);

src/app/admin/archive/[year]/papers/[id]/edit/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { useRouter, useParams } from "next/navigation";
55
import { toast } from "sonner";
66
import Link from "next/link";
77

8+
export const dynamic = 'force-dynamic';
9+
810
export default function EditArchivePaperPage() {
911
const router = useRouter();
1012
const params = useParams();

src/app/admin/archive/[year]/papers/add/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { useRouter, useParams } from "next/navigation";
55
import { toast } from "sonner";
66
import Link from "next/link";
77

8+
export const dynamic = 'force-dynamic';
9+
810
export default function AddArchivePaperPage() {
911
const router = useRouter();
1012
const params = useParams();

src/app/admin/archive/[year]/papers/import/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { useRouter, useParams } from "next/navigation";
55
import { toast } from "sonner";
66
import Link from "next/link";
77

8+
export const dynamic = 'force-dynamic';
9+
810
interface Paper {
911
id: string;
1012
submissionId: string;

src/app/admin/archive/categories/add/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import { useState } from "react";
44
import { useRouter } from "next/navigation";
55
import { toast } from "sonner";
6+
7+
export const dynamic = 'force-dynamic';
68
import Link from "next/link";
79

810
export default function AddCategoryPage() {

src/app/admin/archive/categories/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Link from "next/link";
22
import { db, archiveCategories } from "@/db/schema";
33

4+
export const dynamic = 'force-dynamic';
5+
46
export default async function CategoriesManagementPage() {
57
const categories = await db.select().from(archiveCategories).orderBy(archiveCategories.displayOrder);
68

src/app/admin/archive/create/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import { useState } from "react";
44
import { useRouter } from "next/navigation";
55
import { toast } from "sonner";
6+
import Image from "next/image";
7+
8+
export const dynamic = 'force-dynamic';
69

710
export default function CreateArchiveYearPage() {
811
const router = useRouter();
@@ -176,7 +179,9 @@ export default function CreateArchiveYearPage() {
176179
{coverImageUrl && (
177180
<div className="mt-2">
178181
<p className="text-sm text-green-600">Image uploaded: {coverImageUrl}</p>
179-
<img src={coverImageUrl} alt="Cover preview" className="mt-2 w-32 h-32 object-cover rounded" />
182+
<div className="relative w-32 h-32 mt-2">
183+
<Image src={coverImageUrl} alt="Cover preview" fill className="object-cover rounded" />
184+
</div>
180185
</div>
181186
)}
182187
<p className="text-xs text-muted-foreground mt-1">

src/app/admin/archive/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import Link from "next/link";
22
import { db, archiveYears } from "@/db/schema";
33
import { desc } from "drizzle-orm";
44

5+
export const dynamic = 'force-dynamic';
6+
57
export default async function AdminArchivePage() {
68
const years = await db.select().from(archiveYears).orderBy(desc(archiveYears.year));
79

0 commit comments

Comments
 (0)