import { calcReadingTime } from '@/utils/readingTime'; import { useEffect, useState } from 'react'; import { useParams } from 'react-router-dom'; export function Post() { const { slug } = useParams<{ slug: string }>(); const [post, setPost] = useState<{ html: string, data: Record } | null>(null); const [isLoading, setIsLoading] = useState(true); useEffect(() => { import(`../posts/${slug}.md`) .then((module) => { setPost({ html: module.html, data: module.data }); setIsLoading(false); }) .catch((error) => { console.error('Failed to load post:', error); setIsLoading(false); }); }, [slug]); if (isLoading) { return
hold on...
; } if (!post) { return
post not found :(
; } document.title = post.data.title; return (
Orion Reed

{post.data.title}

{calcReadingTime(post.html)}
); }