Perplexica/ui/components/NewsDetail.tsx

59 lines
1.4 KiB
TypeScript
Raw Normal View History

import React from "react";
import ContextItem from "./ContextItem";
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 {
news: {
title: string;
sections: {
title: string;
content: string;
2024-07-10 11:20:06 +08:00
context: ContextItemType[];
}[];
};
}
2024-07-10 16:34:28 +08:00
const NewsDetail: React.FC<NewsDetailProperties> = ({ news }) => {
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>
{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>
<div className="mt-4">
2024-07-10 12:59:34 +08:00
<h3 className="text-black dark:text-white">Related Context:</h3>
<ExpandableItems context={section.context} />
</div>
</section>
))}
</article>
);
};
2024-07-10 12:05:49 +08:00
export default NewsDetail;