fix:detail news-> get thumbnail to content

This commit is contained in:
Rama Priyanto 2026-02-24 14:09:04 +07:00
parent 19f71eb972
commit 84b84c0fec
1 changed files with 20 additions and 9 deletions

View File

@ -67,22 +67,22 @@ export default function DetailNews(props: { data: any; listArticle: any }) {
switch (platform) { switch (platform) {
case "facebook": case "facebook":
shareLink = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent( shareLink = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(
urls urls,
)}`; )}`;
break; break;
case "x": case "x":
shareLink = `https://x.com/intent/tweet?url=${encodeURIComponent( shareLink = `https://x.com/intent/tweet?url=${encodeURIComponent(
urls urls,
)}&text=${encodeURIComponent(shareText)}`; )}&text=${encodeURIComponent(shareText)}`;
break; break;
case "linkedin": case "linkedin":
shareLink = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent( shareLink = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(
urls urls,
)}`; )}`;
break; break;
case "whatsapp": case "whatsapp":
shareLink = `https://wa.me/?text=${encodeURIComponent( shareLink = `https://wa.me/?text=${encodeURIComponent(
shareText + " " + urls shareText + " " + urls,
)}`; )}`;
break; break;
default: default:
@ -97,14 +97,14 @@ export default function DetailNews(props: { data: any; listArticle: any }) {
window.open( window.open(
shareLink, shareLink,
"_blank", "_blank",
`width=${popupWidth},height=${popupHeight},top=${top},left=${left},resizable=no,scrollbars=no,toolbar=no,menubar=no,status=no` `width=${popupWidth},height=${popupHeight},top=${top},left=${left},resizable=no,scrollbars=no,toolbar=no,menubar=no,status=no`,
); );
}; };
useEffect(() => { useEffect(() => {
if (listArticle) { if (listArticle) {
const index = listArticle?.findIndex( const index = listArticle?.findIndex(
(item: any) => item?.id === data?.id (item: any) => item?.id === data?.id,
); );
if (index - 1 == -1) { if (index - 1 == -1) {
setPrevArticle(""); setPrevArticle("");
@ -165,6 +165,18 @@ export default function DetailNews(props: { data: any; listArticle: any }) {
{data?.viewCount === null ? 0 : data?.viewCount} {data?.viewCount === null ? 0 : data?.viewCount}
</p> </p>
</div> </div>
{data?.files?.length < 1 && data?.thumbnailUrl !== "" && (
<Image
classNames={{
wrapper: "!w-full !max-w-full",
img: "!w-full",
}}
alt="Main Image"
src={data.thumbnailUrl}
className="object-cover w-[100%] rounded-md"
/>
)}{" "}
<div className="flex justify-center my-2 lg:my-5"></div>
<div className="flex justify-center my-2 lg:my-5"> <div className="flex justify-center my-2 lg:my-5">
{data?.files?.length > 0 ? ( {data?.files?.length > 0 ? (
data.files[0]?.file_name.split(".")[1].includes("doc") || data.files[0]?.file_name.split(".")[1].includes("doc") ||
@ -273,11 +285,10 @@ export default function DetailNews(props: { data: any; listArticle: any }) {
))} ))}
<div <div
dangerouslySetInnerHTML={removeImgTags( dangerouslySetInnerHTML={removeImgTags(
formatTextToHtmlTag(data?.htmlDescription) formatTextToHtmlTag(data?.htmlDescription),
)} )}
className="text-sm lg:text-xl lg:leading-8 text-justify space-y-4" className="text-sm lg:text-xl lg:leading-8 text-justify space-y-4"
/> />
<div className="bg-gray-50 dark:bg-black text-black dark:text-white rounded-lg justify-center items-center p-4 flex flex-col gap-3"> <div className="bg-gray-50 dark:bg-black text-black dark:text-white rounded-lg justify-center items-center p-4 flex flex-col gap-3">
<p className="text-lg border-b-3 border-red-600 font-semibold">TAGS</p> <p className="text-lg border-b-3 border-red-600 font-semibold">TAGS</p>
<div className="flex flex-wrap gap-2"> <div className="flex flex-wrap gap-2">
@ -306,7 +317,7 @@ export default function DetailNews(props: { data: any; listArticle: any }) {
{tag} {tag}
</Button> </Button>
</Link> </Link>
) ),
)} )}
</div> </div>
</div> </div>