Skip to content

Commit

Permalink
some fix around index and page listing
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed Apr 20, 2024
1 parent 648996d commit 46838d8
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion quartz/components/ArticleTitle.tsx
Original file line number Diff line number Diff line change
@@ -5,7 +5,11 @@ import { QuartzComponentConstructor, QuartzComponentProps } from "./types";
export default ((opts?: Partial<IconFolderOptions>) => {
function ArticleTitle(props: QuartzComponentProps) {
const { displayClass, fileData } = props;
const title = fileData.frontmatter?.title;
let title = fileData.frontmatter?.title ?? fileData.slug;
if (title === "index") {
const path = fileData.slug?.split("/");
title = path?.[path.length - 2].replaceAll("-", " ") ?? "index";
}
const iconType = (fileData.frontmatter?.icon as string) || opts?.default?.file;
if (title) {
if (!opts?.rootIconFolder || !iconType) {
5 changes: 2 additions & 3 deletions quartz/components/PageList.tsx
Original file line number Diff line number Diff line change
@@ -41,10 +41,10 @@ export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit }: Pr
return (
<ul class="section-ul">
{list.map((page) => {
let title = page.frontmatter?.title;
let title = page.frontmatter?.title ?? page.slug;
if (title === "index") {
const path = page.slug?.split("/");
title = path?.[path.length - 2].replace("-", " ") ?? "index";
title = path?.[path.length - 2].replaceAll("-", " ") ?? "index";
}
const tags = page.frontmatter?.tags ?? [];
const description = page.frontmatter?.description;
@@ -58,7 +58,6 @@ export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit }: Pr
return (
<li class="section-li">
<div class="section">

<div class="desc">
<h3>
<a href={resolveRelative(fileData.slug!, page.slug!)} class="internal">
7 changes: 4 additions & 3 deletions quartz/components/pages/FolderContent.tsx
Original file line number Diff line number Diff line change
@@ -42,13 +42,14 @@ export default ((opts?: Partial<FolderContentOptions>) => {

const content =
(tree as Root).children.length === 0
? fileData.description
? undefined
: htmlToJsx(fileData.filePath!, tree);

const descFontmatter = fileData.frontmatter?.description;
const descContent = descFontmatter ? descFontmatter : content;
return (
<div class={classNames(undefined, "popover-hint", ...cssClasses)}>
<article>
<p>{content}</p>
<p>{descContent}</p>
</article>
{(!content || content?.props?.children?.length === 0) && (
<div class="page-listing">

0 comments on commit 46838d8

Please sign in to comment.