2023-11-06 17:27:50 +08:00
|
|
|
|
import { articleDetail, listArticles } from "@/app/_services/articles";
|
2023-11-01 17:27:06 +08:00
|
|
|
|
import Link from "next/link";
|
|
|
|
|
import Image from "next/image";
|
|
|
|
|
import { htmlToText } from "html-to-text";
|
|
|
|
|
|
|
|
|
|
const LatestNews = async () => {
|
|
|
|
|
const { lists } = await listArticles({
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
cid: "4",
|
|
|
|
|
pageSize: 1,
|
|
|
|
|
sort: "new",
|
|
|
|
|
});
|
2023-11-01 22:25:06 +08:00
|
|
|
|
if (!lists?.length) {
|
2023-11-01 17:27:06 +08:00
|
|
|
|
return <></>;
|
|
|
|
|
}
|
|
|
|
|
const { id } = lists[0];
|
|
|
|
|
const article = await articleDetail({
|
|
|
|
|
id: `${id}`,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const content = htmlToText(article.content, {
|
|
|
|
|
selectors: [{ selector: "img", format: "skip" }],
|
|
|
|
|
});
|
2023-11-01 22:25:06 +08:00
|
|
|
|
|
2023-11-01 17:27:06 +08:00
|
|
|
|
return (
|
2023-11-03 17:25:10 +08:00
|
|
|
|
<div className={"flex h-[180px] bg-white p-2"}>
|
2023-11-01 17:27:06 +08:00
|
|
|
|
<Link
|
|
|
|
|
href={`general-news/${lists[0].id}`}
|
|
|
|
|
className={"article-cover w-[207px]"}
|
|
|
|
|
>
|
2023-11-01 22:25:06 +08:00
|
|
|
|
<img
|
2023-11-03 17:25:10 +08:00
|
|
|
|
className={"h-full w-full object-cover"}
|
2023-11-15 09:48:16 +08:00
|
|
|
|
src={
|
|
|
|
|
article.image
|
|
|
|
|
? `${
|
|
|
|
|
process.env.NEXT_PUBLIC_CLIENT_BASE_URL
|
|
|
|
|
}${article.image.match(/\/uploads\/.*/)?.[0]}`
|
|
|
|
|
: undefined
|
|
|
|
|
}
|
2023-11-01 22:25:06 +08:00
|
|
|
|
alt={""}
|
|
|
|
|
/>
|
2023-11-01 17:27:06 +08:00
|
|
|
|
</Link>
|
2023-11-03 17:25:10 +08:00
|
|
|
|
<div className={"relative ml-1 w-0 flex-1"}>
|
2023-11-01 17:27:06 +08:00
|
|
|
|
<Link
|
|
|
|
|
href={`general-news/${lists[0].id}`}
|
2023-11-03 17:25:10 +08:00
|
|
|
|
className={"title block truncate text-base text-[#186ab6]"}
|
2023-11-01 17:27:06 +08:00
|
|
|
|
>
|
|
|
|
|
{article.title}
|
|
|
|
|
</Link>
|
|
|
|
|
<Link
|
|
|
|
|
href={`general-news/${lists[0].id}`}
|
2023-11-03 17:25:10 +08:00
|
|
|
|
className={"content line-clamp-4 text-xs leading-7"}
|
2023-11-01 17:27:06 +08:00
|
|
|
|
>
|
|
|
|
|
{content}
|
|
|
|
|
</Link>
|
|
|
|
|
<Link
|
|
|
|
|
href={"/general-news/pages/1"}
|
2023-11-03 17:25:10 +08:00
|
|
|
|
className={"absolute bottom-0 left-0 text-xs text-[#ffc001]"}
|
2023-11-01 17:27:06 +08:00
|
|
|
|
>
|
|
|
|
|
更多新闻内容>>
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default LatestNews;
|