Skip to content

Commit 9d77eda

Browse files
committed
fix description not being used in folder and tag listings
1 parent 0ef1b5b commit 9d77eda

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

quartz/components/pages/FolderContent.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import path from "path"
66
import style from "../styles/listPage.scss"
77
import { PageList } from "../PageList"
88
import { _stripSlashes, simplifySlug } from "../../util/path"
9+
import { Root } from "hast"
910

1011
function FolderContent(props: QuartzComponentProps) {
1112
const { tree, fileData, allFiles } = props
@@ -24,8 +25,11 @@ function FolderContent(props: QuartzComponentProps) {
2425
allFiles: allPagesInFolder,
2526
}
2627

27-
// @ts-ignore
28-
const content = toJsxRuntime(tree, { Fragment, jsx, jsxs, elementAttributeNameCase: "html" })
28+
const content = (tree as Root).children.length === 0 ?
29+
fileData.description :
30+
// @ts-ignore
31+
toJsxRuntime(tree, { Fragment, jsx, jsxs, elementAttributeNameCase: "html" })
32+
2933
return (
3034
<div class="popover-hint">
3135
<article>{content}</article>

quartz/components/pages/TagContent.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import style from "../styles/listPage.scss"
55
import { PageList } from "../PageList"
66
import { FullSlug, getAllSegmentPrefixes, simplifySlug } from "../../util/path"
77
import { QuartzPluginData } from "../../plugins/vfile"
8+
import { Root } from "hast"
89

910
const numPages = 10
1011
function TagContent(props: QuartzComponentProps) {
@@ -21,8 +22,11 @@ function TagContent(props: QuartzComponentProps) {
2122
(file.frontmatter?.tags ?? []).flatMap(getAllSegmentPrefixes).includes(tag),
2223
)
2324

24-
// @ts-ignore
25-
const content = toJsxRuntime(tree, { Fragment, jsx, jsxs, elementAttributeNameCase: "html" })
25+
const content = (tree as Root).children.length === 0 ?
26+
fileData.description :
27+
// @ts-ignore
28+
toJsxRuntime(tree, { Fragment, jsx, jsxs, elementAttributeNameCase: "html" })
29+
2630
if (tag === "") {
2731
const tags = [...new Set(allFiles.flatMap((data) => data.frontmatter?.tags ?? []))]
2832
const tagItemMap: Map<string, QuartzPluginData[]> = new Map()

0 commit comments

Comments
 (0)