From 9123f32a0e66e4671a5fa7e13181671bfe22b5d4 Mon Sep 17 00:00:00 2001 From: Kalidou Diagne Date: Thu, 12 Jun 2025 02:03:29 +0800 Subject: [PATCH] copy entire content directory into the standalone build --- lib/markdownContentFetch.ts | 17 ++++++++++++----- vercel.json | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/markdownContentFetch.ts b/lib/markdownContentFetch.ts index 686c916..b2ca93b 100644 --- a/lib/markdownContentFetch.ts +++ b/lib/markdownContentFetch.ts @@ -127,11 +127,20 @@ export async function getMarkdownFiles( // Try multiple potential paths where content might be in Vercel const potentialPaths = [ - // Standard development path - check this first - path.resolve(process.cwd(), folderName), - // Vercel standalone build paths + // Vercel standalone build paths (prioritize these since we copy content here) path.resolve(process.cwd(), ".next", "standalone", folderName), + path.resolve( + process.cwd(), + ".next", + "standalone", + "content", + folderName.replace("content/", "") + ), + // Standard development path + path.resolve(process.cwd(), folderName), + // Other Vercel paths path.resolve(process.cwd(), ".next", "server", folderName), + path.resolve(process.cwd(), ".next", folderName), // Public directory (fallback option) path.resolve(process.cwd(), "public", folderName), path.resolve(process.cwd(), ".next", "standalone", "public", folderName), @@ -142,8 +151,6 @@ export async function getMarkdownFiles( path.resolve(__dirname, "..", folderName), path.resolve(__dirname, "..", "..", folderName), path.resolve(__dirname, "..", "..", "..", folderName), - // Check in .next directory structure - path.resolve(process.cwd(), ".next", folderName), ] console.log("Trying potential paths:") diff --git a/vercel.json b/vercel.json index 1d06f39..039c6d9 100644 --- a/vercel.json +++ b/vercel.json @@ -1,8 +1,7 @@ { "functions": { "app/api/**": { - "maxDuration": 30, - "includeFiles": "content/**" + "maxDuration": 30 } }, "regions": ["iad1"], @@ -11,5 +10,6 @@ "NEXT_TELEMETRY_DISABLED": "1" } }, + "buildCommand": "next build && cp -r content .next/standalone/", "crons": [] }