2024-07-10 11:00:11 +08:00
|
|
|
import React from "react";
|
|
|
|
import Image from "next/image";
|
2024-07-10 16:23:41 +08:00
|
|
|
import { ReactMarkdown } from "@/components/Markdown";
|
2024-07-10 11:00:11 +08:00
|
|
|
|
2024-07-10 16:34:28 +08:00
|
|
|
interface ContextItemProperties {
|
2024-07-10 11:00:11 +08:00
|
|
|
item: {
|
|
|
|
name: string;
|
|
|
|
url: string;
|
|
|
|
description: string;
|
2024-07-11 11:06:58 +08:00
|
|
|
provider: {
|
|
|
|
name: string;
|
|
|
|
image?: {
|
|
|
|
thumbnail: {
|
|
|
|
contentUrl: string;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}[];
|
2024-07-10 11:00:11 +08:00
|
|
|
datePublished: string;
|
|
|
|
image?: {
|
|
|
|
contentUrl: string;
|
|
|
|
thumbnail: { contentUrl: string; width: number; height: number };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-07-10 16:34:28 +08:00
|
|
|
const ContextItem: React.FC<ContextItemProperties> = ({ item }) => {
|
2024-07-10 11:00:11 +08:00
|
|
|
return (
|
2024-07-10 12:59:34 +08:00
|
|
|
<div className="border p-4 rounded-lg mb-4 dark:border-gray-700">
|
|
|
|
<h4 className="font-bold text-black dark:text-white">{item.name}</h4>
|
2024-07-10 11:00:11 +08:00
|
|
|
{item.image && (
|
|
|
|
<Image
|
|
|
|
src={item.image.contentUrl}
|
|
|
|
alt={item.name}
|
|
|
|
width={item.image.thumbnail.width}
|
|
|
|
height={item.image.thumbnail.height}
|
|
|
|
className="my-2 rounded"
|
|
|
|
/>
|
|
|
|
)}
|
2024-07-10 16:23:41 +08:00
|
|
|
<div className="text-black dark:text-white">
|
|
|
|
<ReactMarkdown text={item.description} />
|
|
|
|
</div>
|
2024-07-11 11:06:58 +08:00
|
|
|
<a
|
|
|
|
href={item.url}
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
className="text-black dark:text-white hover:underline inline-block mt-2"
|
|
|
|
>
|
2024-07-10 11:00:11 +08:00
|
|
|
Read more
|
|
|
|
</a>
|
2024-07-11 11:06:58 +08:00
|
|
|
<div className="mt-2">
|
|
|
|
<div className="flex items-center text-sm text-gray-700 dark:text-gray-300">
|
|
|
|
{item.provider[0].image && (
|
|
|
|
<Image
|
|
|
|
src={item.provider[0].image.thumbnail.contentUrl}
|
|
|
|
alt={`${item.provider[0].name} logo`}
|
|
|
|
width={16}
|
|
|
|
height={16}
|
|
|
|
className="mr-2"
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{item.provider[0].name}
|
|
|
|
</div>
|
|
|
|
<div className="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
|
|
|
{new Date(item.datePublished).toLocaleDateString()}
|
|
|
|
</div>
|
2024-07-10 13:47:47 +08:00
|
|
|
</div>
|
2024-07-10 11:00:11 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ContextItem;
|