import { useQuery } from "@tanstack/react-query"; import { useRoute } from "wouter"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import PredictionMarketCard from "@/components/PredictionMarketCard"; import type { Article, PredictionMarket } from "@shared/schema"; export default function Article() { const [, params] = useRoute("/articles/:slug"); const { data: article, isLoading: articleLoading } = useQuery
({ queryKey: ["/api/articles", params?.slug], enabled: !!params?.slug }); const { data: predictionMarkets = [], isLoading: marketsLoading } = useQuery({ queryKey: ["/api/prediction-markets", { articleId: article?.id }], enabled: !!article?.id }); if (articleLoading) { return (
{Array.from({ length: 5 }).map((_, i) => (
))}
); } if (!article) { return (

Article Not Found

The article you're looking for doesn't exist.

); } const formatDate = (date: string | Date) => { const d = new Date(date); const now = new Date(); const diffTime = Math.abs(now.getTime() - d.getTime()); const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); if (diffDays === 1) return "1 day ago"; if (diffDays < 7) return `${diffDays} days ago`; return d.toLocaleDateString(); }; return (
{/* Header */}
S
SAPIENS
{/* Article Header */}
Author

Alex Karp

CEO of Palantir

{/* Article Content */}
{article.imageUrl && ( {article.title} )}

{article.title}

{formatDate(article.publishedAt!)} {article.tags?.map((tag) => ( {tag} ))}
{article.excerpt && (

{article.excerpt}

)}
{article.content}
{/* Related Prediction Markets */} {predictionMarkets.length > 0 && (

Related Prediction Markets

{predictionMarkets.slice(0, 3).map((market) => ( ))}
{predictionMarkets.length > 3 && ( )}
)}
); }