change reading time to content meta
1 files deleted
1 files added
3 files modified
| | |
| | | |
| | | // components for pages that display a single page (e.g. a single note) |
| | | export const defaultContentPageLayout: PageLayout = { |
| | | beforeBody: [Component.ArticleTitle(), Component.ReadingTime(), Component.TagList()], |
| | | beforeBody: [Component.ArticleTitle(), Component.ContentMeta(), Component.TagList()], |
| | | left: [ |
| | | Component.PageTitle(), |
| | | Component.MobileOnly(Component.Spacer()), |
| New file |
| | |
| | | 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 |
| | |
| | | date: Date |
| | | } |
| | | |
| | | export function Date({ date }: Props) { |
| | | const formattedDate = date.toLocaleDateString("en-US", { |
| | | export function formatDate(d: Date): string { |
| | | return d.toLocaleDateString("en-US", { |
| | | year: "numeric", |
| | | month: "short", |
| | | day: "2-digit", |
| | | }) |
| | | return <>{formattedDate}</> |
| | | } |
| | | |
| | | export function Date({ date }: Props) { |
| | | return <>{formatDate(date)}</> |
| | | } |
| | |
| | | import Darkmode from "./Darkmode" |
| | | import Head from "./Head" |
| | | import PageTitle from "./PageTitle" |
| | | import ReadingTime from "./ReadingTime" |
| | | import ContentMeta from "./ContentMeta" |
| | | import Spacer from "./Spacer" |
| | | import TableOfContents from "./TableOfContents" |
| | | import TagList from "./TagList" |
| | |
| | | Darkmode, |
| | | Head, |
| | | PageTitle, |
| | | ReadingTime, |
| | | ContentMeta, |
| | | Spacer, |
| | | TableOfContents, |
| | | TagList, |