mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-25 21:16:21 +00:00
c8f5dbbad3
* fix: Fix `Backlinks` not applying the display class Fix #518 * fix: Apply `displayClass` to all layout components * refactor: Use same style * fix: Remove `undefined` class using coalescing operator
30 lines
835 B
TypeScript
30 lines
835 B
TypeScript
import { formatDate, getDate } from "./Date"
|
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
|
import readingTime from "reading-time"
|
|
|
|
export default (() => {
|
|
function ContentMetadata({ cfg, fileData, displayClass }: QuartzComponentProps) {
|
|
const text = fileData.text
|
|
if (text) {
|
|
const segments: string[] = []
|
|
const { text: timeTaken, words: _words } = readingTime(text)
|
|
|
|
if (fileData.dates) {
|
|
segments.push(formatDate(getDate(cfg, fileData)!))
|
|
}
|
|
|
|
segments.push(timeTaken)
|
|
return <p class={`content-meta ${displayClass ?? ""}`}>{segments.join(", ")}</p>
|
|
} else {
|
|
return null
|
|
}
|
|
}
|
|
|
|
ContentMetadata.css = `
|
|
.content-meta {
|
|
margin-top: 0;
|
|
color: var(--gray);
|
|
}
|
|
`
|
|
return ContentMetadata
|
|
}) satisfies QuartzComponentConstructor
|