import { date } from "../lib/date.ts"; import { env } from "../lib/env.ts"; import { Paragraph } from "./typography.tsx"; import type { ComponentChildren } from "preact"; // Calculate reading time based on content length function getReadingTime(content: string): number { const wordsPerMinute = 200; const words = content.trim().split(/\s+/).length; const minutes = Math.max(1, Math.ceil(words / wordsPerMinute)); return minutes; } export function PostInfo({ createdAt, content, includeAuthor = false, className, children, }: { createdAt?: string; content: string; includeAuthor?: boolean; className?: string; children?: ComponentChildren; }) { const readingTime = getReadingTime(content); return ( {includeAuthor && ( <> Roscoe Rubin-Rottenberg {" "} ·{" "} )} {createdAt && ( <> {" "} ·{" "} )} {readingTime} min read {children} ); }