diff --git a/quartz/cfg.ts b/quartz/cfg.ts index a477db05..9f0f2a92 100644 --- a/quartz/cfg.ts +++ b/quartz/cfg.ts @@ -7,18 +7,18 @@ import { Theme } from "./util/theme" export type Analytics = | null | { - provider: "plausible" - host?: string - } + provider: "plausible" + host?: string + } | { - provider: "google" - tagId: string - } + provider: "google" + tagId: string + } | { - provider: "umami" - websiteId: string - host?: string - } + provider: "umami" + websiteId: string + host?: string + } export interface GlobalConfiguration { pageTitle: string @@ -35,6 +35,7 @@ export interface GlobalConfiguration { /** Base URL to use for CNAME files, sitemaps, and RSS feeds that require an absolute URL. * Quartz will avoid using this as much as possible and use relative URLs most of the time */ + repoUrl?: string baseUrl?: string theme: Theme /** diff --git a/quartz/components/ContentMeta.tsx b/quartz/components/ContentMeta.tsx index c63ce3a5..34c5c94c 100644 --- a/quartz/components/ContentMeta.tsx +++ b/quartz/components/ContentMeta.tsx @@ -2,6 +2,7 @@ import { formatDate, getDate } from "./Date" import { QuartzComponentConstructor, QuartzComponentProps } from "./types" import readingTime from "reading-time" import { classNames } from "../util/lang" +import { JSX } from "preact/jsx-runtime" interface ContentMetaOptions { /** @@ -20,23 +21,44 @@ export default ((opts?: Partial) => { function ContentMetadata({ cfg, fileData, displayClass }: QuartzComponentProps) { const text = fileData.text - - if (text) { - const segments: string[] = [] + const filepath = fileData.filePath + if (text && filepath) { + const fileRepoUrl: string = `${cfg.repoUrl}/commits/branch/v4/${filepath}` + const segments: JSX.Element[] = [] + // const segments: string[] = [] if (fileData.dates?.created) { - segments.push('created: ' + formatDate(fileData.dates.created, cfg.locale)) + segments.push(created: {formatDate(fileData.dates.created, cfg.locale)}) } if (fileData.dates?.modified) { - segments.push('last updated: ' + formatDate(fileData.dates.modified, cfg.locale)) + segments.push( updated: {formatDate(fileData.dates.modified, cfg.locale)}) } // Display reading time if enabled if (options.showReadingTime) { const { text: timeTaken, words: _words } = readingTime(text) - segments.push(timeTaken) + segments.push({timeTaken}) } + segments.push( + + view history + + , + ) - return

{segments.join(", ")}

+ + return ( +

+ {segments.map((meta, idx) => ( + <> + {meta} + + ))} +

+ ) } else { return null } @@ -47,6 +69,9 @@ export default ((opts?: Partial) => { margin-top: 0; color: var(--gray); } + .content-meta span{ + margin-right: 10px; + } ` return ContentMetadata }) satisfies QuartzComponentConstructor