import { createRootRoute, createRoute, createRouter, Outlet, Link } from '@tanstack/react-router'
import { useQuery } from '@tanstack/react-query'
import * as api from './lib/api'
import './styles.css'
function ArticleTicker() {
const { data } = useQuery({
queryKey: ['ticker-articles'],
queryFn: () => api.fetchArticles({ status: 'published', limit: 10 }),
})
const articles = data?.data.slice(0, 10) || []
if (articles.length === 0) return null
return (
Latest:
{articles.map((article, index) => (
{article.title || 'No title'}
))}
{/* Duplicate for seamless scrolling */}
{articles.map((article, index) => (
{article.title || 'No title'}
))}
)
}
const rootRoute = createRootRoute({
head: () => ({
meta: [
{
title: 'Placebo.mk - Sarcastic News from Macedonia',
description: 'Latest news and articles from Macedonia with a sarcastic twist',
},
],
}),
component: () => (
),
})
const indexRoute = createRoute({
getParentRoute: () => rootRoute,
path: '/',
component: () => (
Placebo.mk
Unapologetically sarcastic news and commentary on local and global affairs in Macedonia. Because sometimes the truth hurts more than fiction.
Latest Articles
Freshly brewed sarcasm on current events, politics, and everything in between.
No Filter
We don't do nuance. We don't do diplomatic language. Just honest (and slightly mean) commentary.
Community
Join thousands of readers who appreciate the finer art of Macedonian sarcasm.
),
})
const articlesRoute = createRoute({
getParentRoute: () => rootRoute,
path: '/articles',
component: () => {
const { data, isLoading, error } = useQuery({
queryKey: ['articles'],
queryFn: () => api.fetchArticles({ status: 'published' }),
})
if (isLoading) {
return (
)
}
if (error) {
return (
)
}
return (
Articles
Latest news and articles
{data?.data.map((article) => (
{article.title}
{article.excerpt && (
{article.excerpt}
)}
{new Date(article.createdAt).toLocaleDateString('mk-MK', {
day: 'numeric',
month: 'short',
year: 'numeric',
})}
{article.views} views
))}
{data?.data.length === 0 && (
No articles published yet. Check back soon!
)}
)
},
})
const articleDetailRoute = createRoute({
getParentRoute: () => rootRoute,
path: '/articles/$id',
component: () => {
const { id } = articleDetailRoute.useParams()
const { data, isLoading, error } = useQuery({
queryKey: ['article', id],
queryFn: () => api.fetchArticleById(id),
})
if (isLoading) {
return (
)
}
if (error) {
return (
)
}
if (!data) {
return (
)
}
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.tags && Array.isArray(data.tags) && data.tags.length > 0 && (
Tags
{data.tags.map((tag) => (
{tag}
))}
)}
)
},
})
const routeTree = rootRoute.addChildren([indexRoute, articlesRoute, articleDetailRoute])
export const router = createRouter({ routeTree })
declare module '@tanstack/react-router' {
interface Register {
router: typeof router
}
}