2024-07-10 11:00:11 +08:00
|
|
|
import React from "react";
|
|
|
|
import ContextItem from "./ContextItem";
|
2024-07-18 17:33:59 +08:00
|
|
|
import ExpandableItems from "./ExpandableItems";
|
2024-07-10 11:20:06 +08:00
|
|
|
interface ContextItemType {
|
|
|
|
name: string;
|
|
|
|
url: string;
|
|
|
|
description: string;
|
|
|
|
provider: {
|
|
|
|
name: string;
|
|
|
|
image?: {
|
|
|
|
thumbnail: {
|
|
|
|
contentUrl: string;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}[];
|
|
|
|
datePublished: string;
|
|
|
|
image?: {
|
|
|
|
contentUrl: string;
|
|
|
|
thumbnail: {
|
|
|
|
contentUrl: string;
|
|
|
|
width: number;
|
|
|
|
height: number;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
article?: string;
|
|
|
|
score?: number;
|
|
|
|
}
|
|
|
|
|
2024-07-10 16:34:28 +08:00
|
|
|
interface NewsDetailProperties {
|
2024-07-10 11:00:11 +08:00
|
|
|
news: {
|
|
|
|
title: string;
|
|
|
|
sections: {
|
|
|
|
title: string;
|
|
|
|
content: string;
|
2024-07-10 11:20:06 +08:00
|
|
|
context: ContextItemType[];
|
2024-07-10 11:00:11 +08:00
|
|
|
}[];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-07-10 16:34:28 +08:00
|
|
|
const NewsDetail: React.FC<NewsDetailProperties> = ({ news }) => {
|
2024-07-10 11:00:11 +08:00
|
|
|
return (
|
2024-07-10 12:59:34 +08:00
|
|
|
<article className="prose lg:prose-xl dark:prose-invert">
|
|
|
|
<h1 className="text-black dark:text-white">{news.title}</h1>
|
2024-07-10 11:00:11 +08:00
|
|
|
{news.sections.map((section, index) => (
|
|
|
|
<section key={index}>
|
2024-07-10 12:59:34 +08:00
|
|
|
<h2 className="text-black dark:text-white">{section.title}</h2>
|
|
|
|
<p className="text-black dark:text-white">{section.content}</p>
|
2024-07-10 11:00:11 +08:00
|
|
|
<div className="mt-4">
|
2024-07-10 12:59:34 +08:00
|
|
|
<h3 className="text-black dark:text-white">Related Context:</h3>
|
2024-07-18 17:33:59 +08:00
|
|
|
<ExpandableItems context={section.context} />
|
2024-07-10 11:00:11 +08:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
))}
|
|
|
|
</article>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-07-10 12:05:49 +08:00
|
|
|
export default NewsDetail;
|