import { format } from "date-fns"; const getReadingTime = (body: string | undefined) => { const words = (body ?? "") .replace(/```[\s\S]*?```/g, " ") .replace(/<[^>]+>/g, " ") .match(/\b[\w'-]+\b/g); return Math.max(1, Math.ceil((words?.length ?? 0) / 220)); }; const BlogPost = ({ post, children, }: { post: any; children: React.ReactNode; }) => { const { title, pubDate } = post.data; const readingTime = getReadingTime(post.body); return (

{title}

{readingTime} min read
{children}
); }; export { BlogPost };