feat(blog): enhance blog data handling with normalization and improved image management
This commit is contained in:
@@ -1,39 +1,13 @@
|
||||
"use client";
|
||||
import { useState, useEffect } from "react";
|
||||
import CustomLoading from "@/app/component/loading/Custom";
|
||||
import TextLoading from "@/app/component/loading/Text";
|
||||
import Link from "next/link";
|
||||
import { request } from "@/services/response";
|
||||
|
||||
// نمایش «بلاگهای برتر» فعلاً غیرفعال است (endpoint /api/v1/blogs/top در بکاند وجود ندارد).
|
||||
// markup زیر برای فعالسازی بعدی نگه داشته شده؛ تا آن زمان کامپوننت چیزی رندر نمیکند.
|
||||
function Head() {
|
||||
const [topBlogs, setTopBlogs] = useState([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
return null;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const fetchTopBlogs = async () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const response = await request.getTopBlogs();
|
||||
setTopBlogs(response || []);
|
||||
} catch (error) {
|
||||
console.error("Error fetching top blogs:", error);
|
||||
setTopBlogs([]);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchTopBlogs();
|
||||
}, []);
|
||||
|
||||
if (isLoading || topBlogs.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const [firstBlog, secondBlog, thirdBlog, fourthBlog] = topBlogs;
|
||||
|
||||
return (
|
||||
<>{/*
|
||||
/* eslint-disable */
|
||||
/*
|
||||
<div className="flex flex-col lg:flex-row mt-[40px] items-center justify-center gap-[16px] sm:gap-[19px] md:gap-[22px] lg:gap-[24px]">
|
||||
{firstBlog && (
|
||||
<Link href={`/blog/${firstBlog.uuid}`} className="w-full lg:w-1/2 cover-head-blogs">
|
||||
@@ -104,8 +78,6 @@ function Head() {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
*/}</>
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
export default Head;
|
||||
|
||||
Reference in New Issue
Block a user