From c538c151c7462ad0395ff2c15c5e11e89e362aa8 Mon Sep 17 00:00:00 2001
From: Striven <sg.striven@cutecat.club>
Date: Sat, 04 Apr 2026 19:47:16 +0000
Subject: [PATCH] Initial commit
---
quartz/plugins/emitters/contentIndex.tsx | 72 +++++++++++-------------------------
1 files changed, 22 insertions(+), 50 deletions(-)
diff --git a/quartz/plugins/emitters/contentIndex.tsx b/quartz/plugins/emitters/contentIndex.tsx
index 0cc70d8..56392b3 100644
--- a/quartz/plugins/emitters/contentIndex.tsx
+++ b/quartz/plugins/emitters/contentIndex.tsx
@@ -7,11 +7,11 @@
import { toHtml } from "hast-util-to-html"
import { write } from "./helpers"
import { i18n } from "../../i18n"
-import DepGraph from "../../depgraph"
export type ContentIndexMap = Map<FullSlug, ContentDetails>
export type ContentDetails = {
slug: FullSlug
+ filePath: FilePath
title: string
links: SimpleSlug[]
tags: string[]
@@ -58,7 +58,7 @@
<title>${escapeHTML(content.title)}</title>
<link>https://${joinSegments(base, encodeURI(slug))}</link>
<guid>https://${joinSegments(base, encodeURI(slug))}</guid>
- <description>${content.richContent ?? content.description}</description>
+ <description><![CDATA[ ${content.richContent ?? content.description} ]]></description>
<pubDate>${content.date?.toUTCString()}</pubDate>
</item>`
@@ -96,29 +96,8 @@
opts = { ...defaultOptions, ...opts }
return {
name: "ContentIndex",
- async getDependencyGraph(ctx, content, _resources) {
- const graph = new DepGraph<FilePath>()
-
- for (const [_tree, file] of content) {
- const sourcePath = file.data.filePath!
-
- graph.addEdge(
- sourcePath,
- joinSegments(ctx.argv.output, "static/contentIndex.json") as FilePath,
- )
- if (opts?.enableSiteMap) {
- graph.addEdge(sourcePath, joinSegments(ctx.argv.output, "sitemap.xml") as FilePath)
- }
- if (opts?.enableRSS) {
- graph.addEdge(sourcePath, joinSegments(ctx.argv.output, "index.xml") as FilePath)
- }
- }
-
- return graph
- },
- async emit(ctx, content, _resources) {
+ async *emit(ctx, content) {
const cfg = ctx.cfg.configuration
- const emitted: FilePath[] = []
const linkIndex: ContentIndexMap = new Map()
for (const [tree, file] of content) {
const slug = file.data.slug!
@@ -126,6 +105,7 @@
if (opts?.includeEmptyFiles || (file.data.text && file.data.text !== "")) {
linkIndex.set(slug, {
slug,
+ filePath: file.data.relativePath!,
title: file.data.frontmatter?.title!,
links: file.data.links ?? [],
tags: file.data.frontmatter?.tags ?? [],
@@ -140,25 +120,21 @@
}
if (opts?.enableSiteMap) {
- emitted.push(
- await write({
- ctx,
- content: generateSiteMap(cfg, linkIndex),
- slug: "sitemap" as FullSlug,
- ext: ".xml",
- }),
- )
+ yield write({
+ ctx,
+ content: generateSiteMap(cfg, linkIndex),
+ slug: "sitemap" as FullSlug,
+ ext: ".xml",
+ })
}
if (opts?.enableRSS) {
- emitted.push(
- await write({
- ctx,
- content: generateRSSFeed(cfg, linkIndex, opts.rssLimit),
- slug: (opts?.rssSlug ?? "index") as FullSlug,
- ext: ".xml",
- }),
- )
+ yield write({
+ ctx,
+ content: generateRSSFeed(cfg, linkIndex, opts.rssLimit),
+ slug: (opts?.rssSlug ?? "index") as FullSlug,
+ ext: ".xml",
+ })
}
const fp = joinSegments("static", "contentIndex") as FullSlug
@@ -173,16 +149,12 @@
}),
)
- emitted.push(
- await write({
- ctx,
- content: JSON.stringify(simplifiedIndex),
- slug: fp,
- ext: ".json",
- }),
- )
-
- return emitted
+ yield write({
+ ctx,
+ content: JSON.stringify(simplifiedIndex),
+ slug: fp,
+ ext: ".json",
+ })
},
externalResources: (ctx) => {
if (opts?.enableRSS) {
--
Gitblit v1.10.0