feat: update Projects component with framer-motion variants and improve animations
refactor: modify layout to use ClientOnly and BackgroundBlobsClient components fix: correct import statement for ActivityFeed in the main page fix: enhance sitemap fetching logic with error handling and mock support refactor: convert BackgroundBlobs to default export for consistency refactor: simplify ErrorBoundary component and improve error handling UI chore: update framer-motion to version 12.24.10 in package.json and package-lock.json test: add minimal Prisma Client mock for testing purposes feat: create BackgroundBlobsClient for dynamic import of BackgroundBlobs feat: implement ClientOnly component to handle client-side rendering feat: add custom error handling components for better user experience
This commit is contained in:
@@ -14,12 +14,43 @@ export async function GET(request: Request) {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${GHOST_API_URL}/ghost/api/content/posts/slug/${slug}/?key=${GHOST_API_KEY}`,
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch post: ${response.statusText}`);
|
||||
// Debug: show whether fetch is present/mocked
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('DEBUG fetch in fetchProject:', typeof (globalThis as any).fetch, 'globalIsMock:', !!(globalThis as any).fetch?._isMockFunction);
|
||||
// Try global fetch first (as tests often mock it). If it fails or returns undefined,
|
||||
// fall back to dynamically importing node-fetch.
|
||||
let response: any;
|
||||
|
||||
if (typeof (globalThis as any).fetch === 'function') {
|
||||
try {
|
||||
response = await (globalThis as any).fetch(
|
||||
`${GHOST_API_URL}/ghost/api/content/posts/slug/${slug}/?key=${GHOST_API_KEY}`,
|
||||
);
|
||||
} catch (e) {
|
||||
response = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (!response || typeof response.ok === 'undefined') {
|
||||
try {
|
||||
const mod = await import('node-fetch');
|
||||
const nodeFetch = (mod as any).default ?? mod;
|
||||
response = await nodeFetch(
|
||||
`${GHOST_API_URL}/ghost/api/content/posts/slug/${slug}/?key=${GHOST_API_KEY}`,
|
||||
);
|
||||
} catch (err) {
|
||||
response = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Debug: inspect the response returned from the fetch
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('DEBUG fetch response:', response);
|
||||
|
||||
if (!response || !response.ok) {
|
||||
throw new Error(`Failed to fetch post: ${response?.statusText ?? 'no response'}`);
|
||||
}
|
||||
|
||||
const post = await response.json();
|
||||
return NextResponse.json(post);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user