Skip to content

Commit 2dae497

Browse files
committed
feat: display the reading time in a formatted for the locale
The display of the reading time for each page is currently based on the assumption that the page is in English. This change makes the Intl API is used to display the reading time in a format appropriate for the locale of the translated language.
1 parent e52e6db commit 2dae497

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

apps/site/components/withMetaBar.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ const WithMetaBar: FC = () => {
2020
const lastUpdated = frontmatter.date
2121
? formatter.dateTime(new Date(frontmatter.date), DEFAULT_DATE_FORMAT)
2222
: undefined;
23+
const readingTimeText = formatter.number(Math.round(readingTime.minutes), {
24+
style: 'unit',
25+
unit: 'minute',
26+
});
2327

2428
const usernames =
2529
frontmatter.authors?.split(',').map(author => author.trim()) ?? [];
@@ -39,7 +43,7 @@ const WithMetaBar: FC = () => {
3943
<MetaBar
4044
items={{
4145
'components.metabar.lastUpdated': lastUpdated,
42-
'components.metabar.readingTime': readingTime.text,
46+
'components.metabar.readingTime': readingTimeText,
4347
...(usernames.length && {
4448
[`components.metabar.${usernames.length > 1 ? 'authors' : 'author'}`]:
4549
(

0 commit comments

Comments
 (0)