feat: add defaultDateType config

This commit is contained in:
Jacky Zhao 2023-08-24 08:56:40 -07:00
parent 98d82415dc
commit c36a9f3fb7
8 changed files with 52 additions and 30 deletions
quartz/components

View file

@ -1,15 +1,16 @@
import { formatDate } from "./Date"
import { formatDate, getDate } from "./Date"
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
import readingTime from "reading-time"
export default (() => {
function ContentMetadata({ fileData }: QuartzComponentProps) {
function ContentMetadata({ cfg, fileData }: QuartzComponentProps) {
const text = fileData.text
if (text) {
const segments: string[] = []
const { text: timeTaken, words: _words } = readingTime(text)
if (fileData.dates?.modified) {
segments.push(formatDate(fileData.dates.modified))
if (fileData.dates) {
segments.push(formatDate(getDate(cfg, fileData)!))
}
segments.push(timeTaken)