feat: include tag hierarchies in tag listing, sort tag listing

This commit is contained in:
Jacky Zhao
2023-12-17 15:09:51 -08:00
parent 55e93e9885
commit 05bea5215f
2 changed files with 6 additions and 1 deletions

View File

@@ -28,7 +28,11 @@ function TagContent(props: QuartzComponentProps) {
: htmlToJsx(fileData.filePath!, tree)
if (tag === "/") {
const tags = [...new Set(allFiles.flatMap((data) => data.frontmatter?.tags ?? []))]
const tags = [
...new Set(
allFiles.flatMap((data) => data.frontmatter?.tags ?? []).flatMap(getAllSegmentPrefixes),
),
].sort((a, b) => a.localeCompare(b))
const tagItemMap: Map<string, QuartzPluginData[]> = new Map()
for (const tag of tags) {
tagItemMap.set(tag, allPagesWithTag(tag))

View File

@@ -40,6 +40,7 @@ export const TagPage: QuartzEmitterPlugin<FullPageLayout> = (userOpts) => {
const tags: Set<string> = new Set(
allFiles.flatMap((data) => data.frontmatter?.tags ?? []).flatMap(getAllSegmentPrefixes),
)
// add base tag
tags.add("index")