sztucznainteligencjadlafirm/app/api/blog/[slug]/route.ts
Adrian Miesikowski a10d92abac first commit
2026-02-10 13:34:42 +01:00

24 lines
669 B
TypeScript

import { NextResponse } from "next/server";
import { getPostBySlug } from "@/lib/blog";
export const dynamic = "force-dynamic";
export async function GET(request: Request, { params }: { params: Promise<{ slug: string }> }) {
try {
const { slug } = await params;
const post = await getPostBySlug(slug);
if (!post) {
return NextResponse.json({ success: false, error: "Post not found" }, { status: 404 });
}
return NextResponse.json({
success: true,
post,
});
} catch (error) {
console.error("API Error:", error);
return NextResponse.json({ success: false, error: "Failed to fetch post" }, { status: 500 });
}
}