File tree 2 files changed +7
-2
lines changed
2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ export default async function Page({
63
63
lastEditLocaleTimestamp,
64
64
isTranslated,
65
65
contributors,
66
+ timeToRead,
66
67
} = await getPageData ( {
67
68
locale,
68
69
slug,
@@ -97,8 +98,7 @@ export default async function Page({
97
98
lastEditLocaleTimestamp = { lastEditLocaleTimestamp }
98
99
contentNotTranslated = { ! isTranslated }
99
100
contributors = { contributors }
100
- // TODO: Remove this once we have a real timeToRead value
101
- timeToRead = { 2 }
101
+ timeToRead = { Math . round ( timeToRead . minutes ) }
102
102
>
103
103
{ content }
104
104
</ Layout >
Original file line number Diff line number Diff line change 1
1
import { MDXRemoteProps } from "next-mdx-remote"
2
+ import readingTime , { ReadTimeResults } from "reading-time"
2
3
3
4
import {
4
5
CommitHistory ,
@@ -32,6 +33,7 @@ interface PageData {
32
33
lastEditLocaleTimestamp : string
33
34
contributors : FileContributor [ ]
34
35
isTranslated : boolean
36
+ timeToRead : ReadTimeResults
35
37
}
36
38
37
39
export async function getPageData ( {
@@ -76,12 +78,15 @@ export async function getPageData({
76
78
lastUpdatedDate
77
79
)
78
80
81
+ const timeToRead = readingTime ( markdown )
82
+
79
83
return {
80
84
content,
81
85
frontmatter,
82
86
tocItems : tocItems as ToCItem [ ] ,
83
87
lastEditLocaleTimestamp,
84
88
contributors,
85
89
isTranslated,
90
+ timeToRead,
86
91
}
87
92
}
You can’t perform that action at this time.
0 commit comments