mirror of
https://github.com/alrayyes/wiki.git
synced 2025-05-24 08:39:01 +00:00
feat(i18n): localize the min read string (#838)
* feat(i18n): localize the min read string fixes #825 * chore: format
This commit is contained in:
parent
ab80eba794
commit
3518ca9e2a
11 changed files with 41 additions and 2 deletions
quartz/components
|
@ -2,6 +2,7 @@ import { formatDate, getDate } from "./Date"
|
|||
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||
import readingTime from "reading-time"
|
||||
import { classNames } from "../util/lang"
|
||||
import { i18n } from "../i18n"
|
||||
|
||||
interface ContentMetaOptions {
|
||||
/**
|
||||
|
@ -30,8 +31,11 @@ export default ((opts?: Partial<ContentMetaOptions>) => {
|
|||
|
||||
// Display reading time if enabled
|
||||
if (options.showReadingTime) {
|
||||
const { text: timeTaken, words: _words } = readingTime(text)
|
||||
segments.push(timeTaken)
|
||||
const { minutes, words: _words } = readingTime(text)
|
||||
const displayedTime = i18n(cfg.locale).components.contentMeta.readingTime({
|
||||
minutes: Math.ceil(minutes),
|
||||
})
|
||||
segments.push(displayedTime)
|
||||
}
|
||||
|
||||
return <p class={classNames(displayClass, "content-meta")}>{segments.join(", ")}</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue