web-humas-fe/app/news/detail/[id]/page.tsx

34 lines
928 B
TypeScript
Raw Normal View History

import { HumasLayout } from "@/components/layout/humas-layout";
2024-11-05 06:15:40 +00:00
import DetailPage from "@/components/main/detail/new-detail";
2025-06-09 09:51:44 +00:00
import { getArticleById } from "@/services/article";
2025-03-14 07:50:34 +00:00
import { Metadata } from "next";
2024-02-19 08:39:35 +00:00
2025-03-14 07:50:34 +00:00
type Props = {
params: { id: string };
};
2025-05-19 03:33:49 +00:00
export async function generateMetadata({ params }: any): Promise<Metadata> {
2025-05-20 08:53:32 +00:00
const res = await getArticleById(params.id?.split("-")[0]);
2025-05-19 03:33:49 +00:00
const article = res?.data?.data;
return {
title: article.title,
description: article.description,
openGraph: {
title: article.title,
description: article.description,
images: [`${article.thumbnailUrl}`],
},
};
}
2025-03-14 07:50:34 +00:00
2025-04-17 13:04:04 +00:00
export default async function NewsPage({ params }: any) {
2025-03-14 07:50:34 +00:00
const articleId = params.id?.split("-")[0];
2025-05-20 08:53:32 +00:00
const res = await getArticleById(articleId);
2025-03-14 07:50:34 +00:00
const article = res?.data?.data;
return (
<HumasLayout>
2025-03-14 07:50:34 +00:00
<DetailPage datas={article} />
</HumasLayout>
);
2024-02-19 08:39:35 +00:00
}