commit 894a60a5253ec8c3b230611a94d3ee61e5448b93
parent 6281b505df3eada37e8cb6efc78e5d444eabb9d2
Author: Henry Unite <unitehenry@gmail.com>
Date: Mon, 11 May 2026 00:08:49 +0000
feat: read more
Diffstat:
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/app/src/App.tsx b/app/src/App.tsx
@@ -34,7 +34,6 @@ interface FeedItemComponentProps {
}
function FeedItemComponent({ item }: FeedItemComponentProps) {
- const [isOpen, setIsOpen] = useState(false)
const previewLength = 150
const cleanedText = item.description.replace(/<[^>]*>/g, '').trim()
const shouldTruncate = cleanedText.length > previewLength
@@ -48,21 +47,14 @@ function FeedItemComponent({ item }: FeedItemComponentProps) {
{item.title}
</a>
</h3>
- {!isOpen ? (
- <div>
- <p className="text-sm text-muted-foreground mb-2">{previewText}</p>
- {shouldTruncate && (
- <Button variant="link" onClick={() => setIsOpen(true)} className="block p-0 h-auto text-muted-foreground cursor-pointer mt-2 mb-2">
- Read more
- </Button>
- )}
- </div>
- ) : (
- <div className="text-sm text-muted-foreground mb-2" dangerouslySetInnerHTML={{ __html: displayHtml }} />
- )}
- {isOpen && (
- <Button variant="link" onClick={() => setIsOpen(false)} className="block p-0 h-auto text-muted-foreground mt-2 mb-2 cursor-pointer">
- Read less
+ <p className="text-sm text-muted-foreground mb-2">{previewText}</p>
+ {shouldTruncate && (
+ <Button variant="link" onClick={() => {
+ const blob = new Blob([`<html><body>${displayHtml}</body></html>`], {type: 'text/html'});
+ const url = URL.createObjectURL(blob);
+ window.open(url, '_blank');
+ }} className="block p-0 h-auto text-muted-foreground cursor-pointer mt-2 mb-2">
+ Read more
</Button>
)}
<Badge className="mr-2">{item.feedTitle}</Badge><Badge variant="secondary">{new Date(item.pubDate).toLocaleDateString()}</Badge>