From cf6ab9e9333b5f76cb9e06f6687f2b4f8fbe91bd Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Sun, 12 Nov 2023 22:27:53 +0000
Subject: [PATCH] feat: option to specify npx quartz sync message (closes #583)
---
quartz/plugins/emitters/contentIndex.ts | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/quartz/plugins/emitters/contentIndex.ts b/quartz/plugins/emitters/contentIndex.ts
index 102394c..c5170c6 100644
--- a/quartz/plugins/emitters/contentIndex.ts
+++ b/quartz/plugins/emitters/contentIndex.ts
@@ -13,6 +13,7 @@
links: SimpleSlug[]
tags: string[]
content: string
+ richContent?: string
date?: Date
description?: string
}
@@ -53,11 +54,22 @@
<title>${escapeHTML(content.title)}</title>
<link>${root}/${encodeURI(slug)}</link>
<guid>${root}/${encodeURI(slug)}</guid>
- <description>${content.content}</description>
+ <description>${content.richContent ?? content.description}</description>
<pubDate>${content.date?.toUTCString()}</pubDate>
</item>`
const items = Array.from(idx)
+ .sort(([_, f1], [__, f2]) => {
+ if (f1.date && f2.date) {
+ return f2.date.getTime() - f1.date.getTime()
+ } else if (f1.date && !f2.date) {
+ return -1
+ } else if (!f1.date && f2.date) {
+ return 1
+ }
+
+ return f1.title.localeCompare(f2.title)
+ })
.map(([slug, content]) => createURLEntry(simplifySlug(slug), content))
.slice(0, limit ?? idx.size)
.join("")
@@ -67,9 +79,9 @@
<channel>
<title>${escapeHTML(cfg.pageTitle)}</title>
<link>${root}</link>
- <description>${!!limit ? `Last ${limit} notes` : "Recent notes"} on ${
- cfg.pageTitle
- }</description>
+ <description>${!!limit ? `Last ${limit} notes` : "Recent notes"} on ${escapeHTML(
+ cfg.pageTitle,
+ )}</description>
<generator>Quartz -- quartz.jzhao.xyz</generator>
${items}
</channel>
@@ -92,9 +104,10 @@
title: file.data.frontmatter?.title!,
links: file.data.links ?? [],
tags: file.data.frontmatter?.tags ?? [],
- content: opts?.rssFullHtml
+ content: file.data.text ?? "",
+ richContent: opts?.rssFullHtml
? escapeHTML(toHtml(tree as Root, { allowDangerousHtml: true }))
- : file.data.description ?? "",
+ : undefined,
date: date,
description: file.data.description ?? "",
})
--
Gitblit v1.10.0