From 5a36e5b68d9d49ddcbfc87421216bfa6b9d913cf Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Fri, 02 Feb 2024 08:29:45 +0000
Subject: [PATCH] fix(style): reasonable page width for rich search preview
---
quartz/plugins/transformers/ofm.ts | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts
index d58eaf6..44df3fa 100644
--- a/quartz/plugins/transformers/ofm.ts
+++ b/quartz/plugins/transformers/ofm.ts
@@ -383,14 +383,17 @@
const calloutType = canonicalizeCallout(typeString.toLowerCase())
const collapse = collapseChar === "+" || collapseChar === "-"
const defaultState = collapseChar === "-" ? "collapsed" : "expanded"
- const titleContent =
- match.input.slice(calloutDirective.length).trim() || capitalize(calloutType)
+ const titleContent = match.input.slice(calloutDirective.length).trim()
+ const useDefaultTitle = titleContent === "" && restOfTitle.length === 0
const titleNode: Paragraph = {
type: "paragraph",
- children:
- restOfTitle.length === 0
- ? [{ type: "text", value: titleContent + " " }]
- : restOfTitle,
+ children: [
+ {
+ type: "text",
+ value: useDefaultTitle ? capitalize(calloutType) : titleContent + " ",
+ },
+ ...restOfTitle,
+ ],
}
const title = mdastToHtml(titleNode)
--
Gitblit v1.10.0