Skip to content

Commit 84ff401

Browse files
committed
fix: deduplication and slugiication of tags
based on copilot's review
1 parent b91651f commit 84ff401

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

quartz/plugins/emitters/contentIndex.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
getAllSegmentPrefixes,
1010
joinSegments,
1111
simplifySlug,
12+
slugTag,
1213
} from "../../util/path"
1314
import { QuartzEmitterPlugin } from "../types"
1415
import { toHtml } from "hast-util-to-html"
@@ -153,6 +154,9 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
153154
let sortedTags: string[] = []
154155

155156
if (opts.rssTags && opts.rssTags.length > 0) {
157+
// Deduplicate and slugify user-provided tags
158+
const userTags = new Set(opts.rssTags.map((tag) => slugTag(tag)))
159+
156160
// Only include user-specified tags that actually exist in the content
157161
const availableTags = new Set<string>()
158162
for (const [_, content] of linkIndex) {
@@ -161,7 +165,7 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
161165
availableTags.add(tag)
162166
}
163167
}
164-
sortedTags = opts.rssTags.filter((tag) => availableTags.has(tag))
168+
sortedTags = Array.from(userTags).filter((tag) => availableTags.has(tag))
165169
} else if ((opts.rssTagsLimit ?? 0) > 0) {
166170
const tagCounts: Map<string, number> = new Map()
167171

0 commit comments

Comments
 (0)