diff --git a/app/news/detail/[id]/page.tsx b/app/news/detail/[id]/page.tsx index e21d5e9..eabe05f 100644 --- a/app/news/detail/[id]/page.tsx +++ b/app/news/detail/[id]/page.tsx @@ -1,29 +1,29 @@ import { HumasLayout } from "@/components/layout/humas-layout"; import DetailPage from "@/components/main/detail/new-detail"; -import { getArticleById } from "@/services/article"; +import { getArticleById, getArticleByIdHumas } from "@/services/article"; import { Metadata } from "next"; type Props = { params: { id: string }; }; -// export async function generateMetadata({ params }: any): Promise { -// const res = await getArticleById(params.id?.split("-")[0]); -// const article = res?.data?.data; -// return { -// title: article.title, -// description: article.description, -// openGraph: { -// title: article.title, -// description: article.description, -// images: [`${article.thumbnailUrl}`], -// }, -// }; -// } +export async function generateMetadata({ params }: any): Promise { + const res = await getArticleByIdHumas(params.id?.split("-")[0]); + const article = res?.data?.data; + return { + title: article.title, + description: article.description, + openGraph: { + title: article.title, + description: article.description, + images: [`${article.thumbnailUrl}`], + }, + }; +} export default async function NewsPage({ params }: any) { const articleId = params.id?.split("-")[0]; - const res = await getArticleById(articleId); + const res = await getArticleByIdHumas(articleId); const article = res?.data?.data; return ( diff --git a/components/landing/HeaderNews.tsx b/components/landing/HeaderNews.tsx index 1eff6fa..e3721d6 100644 --- a/components/landing/HeaderNews.tsx +++ b/components/landing/HeaderNews.tsx @@ -69,7 +69,6 @@ export default function HeaderNews() { page: 1, search: "", limit: "10", - sortBy: "view_count", sort: "desc", category: "1906", isPublish: true, diff --git a/components/page/sidebar-detail.tsx b/components/page/sidebar-detail.tsx index 6a2530d..595e6ed 100644 --- a/components/page/sidebar-detail.tsx +++ b/components/page/sidebar-detail.tsx @@ -13,17 +13,33 @@ import { convertDateFormat, textEllipsis } from "@/utils/global"; import Image from "next/image"; export default function SidebarDetail() { + const [articleMabes, setArticleMabes] = useState([]); const [article, setArticle] = useState([]); useEffect(() => { - async function getArticle() { - const req = { page: 1, search: "", limit: "10", isPublish: true }; - - const response = await getListArticle(req); - setArticle(response?.data?.data); - } getArticle(); + getArticleMabes(); }, []); + + async function getArticle() { + const req = { page: 1, search: "", limit: "10", isPublish: true }; + + const response = await getListArticle(req); + setArticle(response?.data?.data); + } + + async function getArticleMabes() { + const req = { + page: 1, + search: "", + limit: "10", + isPublish: true, + category: "1906", + }; + + const response = await getListArticle(req); + setArticleMabes(response?.data?.data); + } return (
@@ -48,7 +64,7 @@ export default function SidebarDetail() { className="mySwiper" slidesPerView={1} > - {article?.map((newsItem: any) => ( + {articleMabes?.map((newsItem: any) => (