From 07793cf8ef4c6b329abb5f207c1e1a1f6bfc7ee9 Mon Sep 17 00:00:00 2001 From: Matt Vogel <> Date: Tue, 10 Sep 2024 09:22:02 +0200 Subject: [PATCH] feat: optional deep link to roam not sure if this is actually useful.. --- content/Experiment Small.md | 1 + package.json | 3 ++- quartz/components/ContentMeta.tsx | 24 ++++++++++++++--------- quartz/components/styles/contentMeta.scss | 21 ++++++++++++++++++++ 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/content/Experiment Small.md b/content/Experiment Small.md index 83936825dc2f..508803441ba0 100644 --- a/content/Experiment Small.md +++ b/content/Experiment Small.md @@ -2,6 +2,7 @@ title: Experiment Small status: budding date: 2023-12-21 +uid: Rv0R2Nhh2 tags: - writing - goals diff --git a/package.json b/package.json index 58235354ef1e..f5937862516d 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "check": "tsc --noEmit && npx prettier . --check", "format": "npx prettier . --write", "test": "tsx ./quartz/util/path.test.ts && tsx ./quartz/depgraph.test.ts", - "profile": "0x -D prof ./quartz/bootstrap-cli.mjs build --concurrency=1" + "profile": "0x -D prof ./quartz/bootstrap-cli.mjs build --concurrency=1", + "serve": "npx quartz build --serve" }, "engines": { "npm": ">=9.3.1", diff --git a/quartz/components/ContentMeta.tsx b/quartz/components/ContentMeta.tsx index efe301052f78..43360ae5a65e 100644 --- a/quartz/components/ContentMeta.tsx +++ b/quartz/components/ContentMeta.tsx @@ -7,9 +7,6 @@ import { JSX } from "preact" import style from "./styles/contentMeta.scss" interface ContentMetaOptions { - /** - * Whether to display reading time - */ showReadingTime: boolean showComma: boolean } @@ -20,12 +17,12 @@ const defaultOptions: ContentMetaOptions = { } export default ((opts?: Partial) => { - // Merge options with defaults const options: ContentMetaOptions = { ...defaultOptions, ...opts } function ContentMetadata({ cfg, fileData, displayClass }: QuartzComponentProps) { const text = fileData.text const status = fileData.frontmatter?.status + const uid = fileData.frontmatter?.uid if (text) { const segments: (string | JSX.Element)[] = [] @@ -34,7 +31,6 @@ export default ((opts?: Partial) => { segments.push(formatDate(getDate(cfg, fileData)!, cfg.locale)) } - // Display reading time if enabled if (options.showReadingTime) { const { minutes, words: _words } = readingTime(text) const displayedTime = i18n(cfg.locale).components.contentMeta.readingTime({ @@ -42,6 +38,7 @@ export default ((opts?: Partial) => { }) segments.push(displayedTime) } + if (status) { const linkDest = `../tags/${status}` const statusElement = ( @@ -55,12 +52,21 @@ export default ((opts?: Partial) => { ) segments.push(statusElement) } + const segmentsElements = segments.map((segment) => {segment}) return ( -

- {segmentsElements} -

+

+ {segmentsElements} + {uid && ( + + + + + + + )} +

) } else { return null @@ -70,4 +76,4 @@ export default ((opts?: Partial) => { ContentMetadata.css = style return ContentMetadata -}) satisfies QuartzComponentConstructor +}) satisfies QuartzComponentConstructor \ No newline at end of file diff --git a/quartz/components/styles/contentMeta.scss b/quartz/components/styles/contentMeta.scss index 4d89f65d565d..ce8d628e4123 100644 --- a/quartz/components/styles/contentMeta.scss +++ b/quartz/components/styles/contentMeta.scss @@ -12,3 +12,24 @@ } } } + +.edit-icon { + opacity: 0; + transition: opacity 0.3s ease; + margin-right: 10px; + color: var(--gray); + flex-shrink: 0; + + svg { + width: 18px; + height: 18px; + } +} + +.content-meta:hover .edit-icon { + opacity: 1; +} + +.edit-icon:hover { + color: var(--secondary); +} \ No newline at end of file