blob: 2c8c6762128a1ba3c394df60bb2d5796c2af2ffd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
---
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" : ""}`;
---
<p>
<data itemprop="timeRequired" value={duration}><bdi>Tempo de leitura
estimado</bdi>: ~ {estimative}</data>
<data itemprop="wordCount" value={reading.words}
>(<bdi>palavras</bdi>: {reading.words})</data>
</p>
|