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' import { YouTubeEmbed } from '@/components/ui/youtube-embed' import { extractYouTubeVideoId, getVideoPositionClasses } from '@/lib/video-utils' import { CommentSection } from '@/components/features/comments/CommentSection' import { ReactionButtons } from '@/components/features/comments/ReactionButtons' import { SocialShareButtons } from '@/components/features/social-share' 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} )}
{/* Social Sharing */}
☕ Купи ми кафе
{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
)} {/* Video rendering */} {data.videoUrl && data.videoPosition !== 'none' && (
)}
( {props.alt ), a: (props) => { // Check if the link is a YouTube URL const videoId = extractYouTubeVideoId(props.href || ''); if (videoId) { return (
); } // Regular link return ; } }} > {data.content}
{/* Social Sharing Footer */}

Share this article:

☕ Купи ми кафе
{data.tags && Array.isArray(data.tags) && data.tags.length > 0 && (

Tags

{data.tags.map((tag) => ( {tag} ))}
)} {/* Reactions */}

Што мислите за овој напис?

{/* Comments */}
) }