| | |
| | | import { pluralize } from "../../util/lang" |
| | | import { htmlToJsx } from "../../util/jsx" |
| | | |
| | | interface FolderContentOptions { |
| | | /** |
| | | * Whether to display number of folders |
| | | */ |
| | | showFolderCount: boolean |
| | | } |
| | | |
| | | const defaultOptions: FolderContentOptions = { |
| | | showFolderCount: true, |
| | | } |
| | | |
| | | export default ((opts?: Partial<FolderContentOptions>) => { |
| | | // Merge options with defaults |
| | | const options: FolderContentOptions = { ...defaultOptions, ...opts } |
| | | |
| | | function FolderContent(props: QuartzComponentProps) { |
| | | const { tree, fileData, allFiles } = props |
| | | const folderSlug = _stripSlashes(simplifySlug(fileData.slug!)) |
| | |
| | | <article> |
| | | <p>{content}</p> |
| | | </article> |
| | | <p>{pluralize(allPagesInFolder.length, "item")} under this folder.</p> |
| | | {options.showFolderCount && <p>{pluralize(allPagesInFolder.length, "item")} under this folder.</p>} |
| | | <div> |
| | | <PageList {...listProps} /> |
| | | </div> |
| | |
| | | } |
| | | |
| | | FolderContent.css = style + PageList.css |
| | | export default (() => FolderContent) satisfies QuartzComponentConstructor |
| | | return FolderContent |
| | | }) satisfies QuartzComponentConstructor |