mirror of
https://github.com/alrayyes/wiki.git
synced 2025-05-20 23:02:13 +00:00
change reading time to content meta
This commit is contained in:
parent
ee9ed4f287
commit
e21f0f9bb9
5 changed files with 40 additions and 31 deletions
quartz/components
31
quartz/components/ContentMeta.tsx
Normal file
31
quartz/components/ContentMeta.tsx
Normal file
|
@ -0,0 +1,31 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue