From 6e3484411495987a1a78c55c714a45e921dda372 Mon Sep 17 00:00:00 2001 From: Mats Fangohr <83273529+MatsFangohr@users.noreply.github.com> Date: Tue, 2 Jan 2024 17:03:05 +0100 Subject: [PATCH 1/5] feat: embed webp images (#666) --- quartz/plugins/transformers/ofm.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts index 5aa09c5bb..8502440ee 100644 --- a/quartz/plugins/transformers/ofm.ts +++ b/quartz/plugins/transformers/ofm.ts @@ -201,7 +201,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin if (value.startsWith("!")) { const ext: string = path.extname(fp).toLowerCase() const url = slugifyFilePath(fp as FilePath) - if ([".png", ".jpg", ".jpeg", ".gif", ".bmp", ".svg"].includes(ext)) { + if ([".png", ".jpg", ".jpeg", ".gif", ".bmp", ".svg", ".webp"].includes(ext)) { const dims = alias ?? "" let [width, height] = dims.split("x", 2) width ||= "auto" From 65d75b8bdcd7376916aed715d5e73732125589fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliv=C3=A9r=20Falvai?= Date: Tue, 2 Jan 2024 18:23:28 +0100 Subject: [PATCH 2/5] feat: support modification date reading from parent git repo (#661) * feat: support modification date reading from parent git repo * Print warning * Fix formatting * Update quartz/plugins/transformers/lastmod.ts Co-authored-by: Jacky Zhao --------- Co-authored-by: Jacky Zhao --- quartz/plugins/transformers/lastmod.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/quartz/plugins/transformers/lastmod.ts b/quartz/plugins/transformers/lastmod.ts index feca4b52f..6e12616f7 100644 --- a/quartz/plugins/transformers/lastmod.ts +++ b/quartz/plugins/transformers/lastmod.ts @@ -57,10 +57,22 @@ export const CreatedModifiedDate: QuartzTransformerPlugin | und published ||= file.data.frontmatter.publishDate } else if (source === "git") { if (!repo) { - repo = new Repository(file.cwd) + // Get a reference to the main git repo. + // It's either the same as the workdir, + // or 1+ level higher in case of a submodule/subtree setup + repo = Repository.discover(file.cwd) } - modified ||= await repo.getFileLatestModifiedDateAsync(file.data.filePath!) + try { + modified ||= await repo.getFileLatestModifiedDateAsync(file.data.filePath!) + } catch { + console.log( + chalk.yellow( + `\nWarning: ${file.data + .filePath!} isn't yet tracked by git, last modification date is not available for this file`, + ), + ) + } } } From 88194ac348222f9e3deed92f6e149da23a644311 Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 2 Jan 2024 13:49:14 -0500 Subject: [PATCH 3/5] feat: allow embedding youtube videos with the obsidian markdown syntax (#665) * Add option to allow embedding YouTube videos with Obsidian Markdown syntax * Update Obsidian compatability doc page * Switch to converting YT links as an html plugin --- docs/features/Obsidian compatibility.md | 1 + quartz/plugins/transformers/ofm.ts | 27 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/docs/features/Obsidian compatibility.md b/docs/features/Obsidian compatibility.md index 61fcc060d..d519e1779 100644 --- a/docs/features/Obsidian compatibility.md +++ b/docs/features/Obsidian compatibility.md @@ -26,6 +26,7 @@ Finally, Quartz also provides `Plugin.CrawlLinks` which allows you to customize - `mermaid`: whether to enable [[Mermaid diagrams]]. Defaults to `true` - `parseTags`: whether to try and parse tags in the content body. Defaults to `true` - `enableInHtmlEmbed`: whether to try and parse Obsidian flavoured markdown in raw HTML. Defaults to `false` + - `enableYouTubeEmbed`: whether to enable embedded YouTube videos using external image Markdown syntax. Defaults to `false` - Link resolution behaviour: - Disabling: remove all instances of `Plugin.CrawlLinks()` from `quartz.config.ts` - Changing link resolution preference: set `markdownLinkResolution` to one of `absolute`, `relative` or `shortest` diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts index 8502440ee..be3344aa4 100644 --- a/quartz/plugins/transformers/ofm.ts +++ b/quartz/plugins/transformers/ofm.ts @@ -25,6 +25,7 @@ export interface Options { parseTags: boolean parseBlockReferences: boolean enableInHtmlEmbed: boolean + enableYouTubeEmbed: boolean } const defaultOptions: Options = { @@ -36,6 +37,7 @@ const defaultOptions: Options = { parseTags: true, parseBlockReferences: true, enableInHtmlEmbed: false, + enableYouTubeEmbed: false, } const icons = { @@ -127,6 +129,7 @@ const calloutLineRegex = new RegExp(/^> *\[\!\w+\][+-]?.*$/, "gm") // (?:\/[-_\p{L}\d\p{Z}]+)*) -> non-capturing group, matches an arbitrary number of tag strings separated by "/" const tagRegex = new RegExp(/(?:^| )#((?:[-_\p{L}\p{Emoji}\d])+(?:\/[-_\p{L}\p{Emoji}\d]+)*)/, "gu") const blockReferenceRegex = new RegExp(/\^([A-Za-z0-9]+)$/, "g") +const ytLinkRegex = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin | undefined> = ( userOpts, @@ -505,6 +508,30 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin }) } + if (opts.enableYouTubeEmbed) { + plugins.push(() => { + return (tree: HtmlRoot) => { + visit(tree, "element", (node) => { + if (node.tagName === "img" && typeof node.properties.src === "string") { + const match = node.properties.src.match(ytLinkRegex) + const videoId = match && match[2].length == 11 ? match[2] : null + if (videoId) { + node.tagName = "iframe" + node.properties = { + class: "external-embed", + allow: "fullscreen", + frameborder: 0, + width: "600px", + height: "350px", + src: `https://www.youtube.com/embed/${videoId}`, + } + } + } + }) + } + }) + } + return plugins }, externalResources() { From 707124cbd6f0ae54924163b6a743506ece681617 Mon Sep 17 00:00:00 2001 From: Nate Silva Date: Tue, 2 Jan 2024 15:19:19 -0800 Subject: [PATCH 4/5] fix: allow publish property to be a string (ExplicitPublish) (#667) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: allow publish property to be a string (ExplicitPublish) Previously, the ExplicitPublish filter would publish if the `publish` property was truthy. The filter expects the `publish` property to be a boolean: ``` --- publish: true --- ``` However, Obsidian only shows the above if you are viewing a page in “Source” mode. If you are not in Source view, and you choose Three Dots Menu (...), “Add file property”, you will get a string, not a boolean. It seems likely that many users will do this and get: ``` publish: "true" ``` Notice that `"true"` is a string, not the boolean value `true`. If the user changes this to `"false"`, the page will still be published: ``` publish: "false" ``` That is because the string value `"false"` is truthy. This PR does the following: - Allows the `publish` property to be either a boolean or a string. - If it’s a string, it’s considered `true` if the string is `"true"` (not case-sensitive; it will also work if it is `"True"`, `"TRUE"`, etc.) - Guarantees that the returned value from `shouldPublish` is a `boolean` -- previously it could be any truthy value even though it was cast to `boolean` * style: use double-quotes everywhere * style: format according to project style guide --- quartz/plugins/filters/explicit.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/quartz/plugins/filters/explicit.ts b/quartz/plugins/filters/explicit.ts index 30f0b37fa..48f92bdf2 100644 --- a/quartz/plugins/filters/explicit.ts +++ b/quartz/plugins/filters/explicit.ts @@ -3,7 +3,11 @@ import { QuartzFilterPlugin } from "../types" export const ExplicitPublish: QuartzFilterPlugin = () => ({ name: "ExplicitPublish", shouldPublish(_ctx, [_tree, vfile]) { - const publishFlag: boolean = vfile.data?.frontmatter?.publish ?? false + const publishProperty = vfile.data?.frontmatter?.publish ?? false + const publishFlag = + typeof publishProperty === "string" + ? publishProperty.toLowerCase() === "true" + : Boolean(publishProperty) return publishFlag }, }) From 5ccc48a1728d68ceb53aeea45a451ecfc4142d52 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Thu, 4 Jan 2024 11:04:57 -0800 Subject: [PATCH 5/5] style: div -> li for explorer --- quartz/components/styles/explorer.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quartz/components/styles/explorer.scss b/quartz/components/styles/explorer.scss index ff046a665..304fd4500 100644 --- a/quartz/components/styles/explorer.scss +++ b/quartz/components/styles/explorer.scss @@ -126,7 +126,7 @@ svg { backface-visibility: visible; } -div:has(> .folder-outer:not(.open)) > .folder-container > svg { +li:has(> .folder-outer:not(.open)) > .folder-container > svg { transform: rotate(-90deg); }