--- import type { CollectionEntry } from "astro:content"; import { default as readingTime } from "reading-time"; type Props = { body: CollectionEntry<"blog">["body"]; lang: CollectionEntry<"blog">["data"]["lang"]; }; const { body, lang } = Astro.props; const reading = readingTime(body ?? "", {}); const minutes = Math.ceil(reading.minutes); const estimative = new Intl.DurationFormat(lang, { style: "long", }).format({ minutes }); const duration = `PT${ Math.floor(minutes / 60) > 0 ? Math.floor(minutes / 60) + "H" : "" }${minutes % 60 > 0 ? minutes % 60 + "M" : ""}`; ---
Tempo de leitura estimado: ~ {estimative} (palavras: {reading.words})