import { useQuery } from '@tanstack/react-query' import { Link } from '@tanstack/react-router' import * as api from '@/lib/api' import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' export function ArticleDetailComponent({ id }: { id: string }) { const { data, isLoading, error } = useQuery({ queryKey: ['article', id], queryFn: () => api.fetchArticleById(id), }) if (isLoading) { return (
Loading article...
) } if (error) { return (
Error loading article
) } if (!data) { return (
Article not found
) } return (
Back to articles

{data.title}

{new Date(data.createdAt).toLocaleDateString('mk-MK', { day: 'numeric', month: 'long', year: 'numeric', })} {data.views} views {data.author && ( <> By {data.author.name} )}
{data.featuredImage && data.imagePosition !== 'none' && (
{data.title} { console.error('Failed to load image:', data.featuredImage, e); e.currentTarget.style.display = 'none'; // Show fallback const fallback = e.currentTarget.nextElementSibling as HTMLElement; if (fallback) { fallback.style.display = 'flex'; } }} />
Image not available
)}
( {props.alt ) }} > {data.content}
{data.tags && Array.isArray(data.tags) && data.tags.length > 0 && (

Tags

{data.tags.map((tag) => ( {tag} ))}
)}
) }