feat: Implement blog API service and refactor components for improved data fetching

This commit is contained in:
Wini_Fy
2026-02-04 15:33:02 +07:00
parent d46c420aaf
commit 9a71d39ebf
16 changed files with 790 additions and 149 deletions

View File

@@ -3,7 +3,7 @@
*
* Rules:
* - If already a full URL (http/https) → return as is
* - If starts with `/uploads/` → prepend API URL (NEXT_PUBLIC_API_URL or default localhost)
* - If starts with `/uploads/` or `/img/` → prepend API URL (NEXT_PUBLIC_API_URL or default localhost)
* - If starts with `/` → use as-is (served by Next/public)
* - Otherwise → treat as relative path under `/`
*/
@@ -14,7 +14,7 @@ export function getCmsImageUrl(imagePath: string | undefined): string {
return imagePath;
}
if (imagePath.startsWith("/uploads/")) {
if (imagePath.startsWith("/uploads/") || imagePath.startsWith("/img/")) {
const apiUrl = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001";
return `${apiUrl}${imagePath}`;
}