| | |
| | | import { formatDate, getDate } from "./Date" |
| | | import { Date, getDate } from "./Date" |
| | | import { QuartzComponentConstructor, QuartzComponentProps } from "./types" |
| | | import readingTime from "reading-time" |
| | | import { classNames } from "../util/lang" |
| | |
| | | const segments: (string | JSX.Element)[] = [] |
| | | |
| | | if (fileData.dates) { |
| | | segments.push(formatDate(getDate(cfg, fileData)!, cfg.locale)) |
| | | segments.push(<Date date={getDate(cfg, fileData)!} locale={cfg.locale} />) |
| | | } |
| | | |
| | | // Display reading time if enabled |
| | |
| | | const displayedTime = i18n(cfg.locale).components.contentMeta.readingTime({ |
| | | minutes: Math.ceil(minutes), |
| | | }) |
| | | segments.push(displayedTime) |
| | | segments.push(<span>{displayedTime}</span>) |
| | | } |
| | | |
| | | const segmentsElements = segments.map((segment) => <span>{segment}</span>) |
| | | |
| | | return ( |
| | | <p show-comma={options.showComma} class={classNames(displayClass, "content-meta")}> |
| | | {segmentsElements} |
| | | {segments} |
| | | </p> |
| | | ) |
| | | } else { |