mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-29 14:36:22 +00:00
29 lines
792 B
TypeScript
29 lines
792 B
TypeScript
import { formatDate } from "./Date"
|
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
|
import readingTime from "reading-time"
|
|
|
|
export default (() => {
|
|
function ContentMetadata({ 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))
|
|
}
|
|
|
|
segments.push(timeTaken)
|
|
return <p class="content-meta">{segments.join(", ")}</p>
|
|
} else {
|
|
return null
|
|
}
|
|
}
|
|
|
|
ContentMetadata.css = `
|
|
.content-meta {
|
|
margin-top: 0;
|
|
color: var(--gray);
|
|
}
|
|
`
|
|
return ContentMetadata
|
|
}) satisfies QuartzComponentConstructor
|