Skip to content

Commit 8eb1554

Browse files
authored
fix(explorer): display names for folders without frontmatter (#494)
* fix(explorer): display name for folders without `index` file * docs(explorer): add section for folder display names
1 parent dcdeae4 commit 8eb1554

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

docs/features/explorer.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Quartz features an explorer that allows you to navigate all files and folders on
88

99
By default, it shows all folders and files on your page. To display the explorer in a different spot, you can edit the [[layout]].
1010

11+
Display names for folders get determined by the `title` frontmatter field in `folder/index.md` (more detail in [[Authoring Content]]). If this file does not exist or does not contain frontmatter, the local folder name will be used instead.
12+
1113
> [!info]
1214
> The explorer uses local storage by default to save the state of your explorer. This is done to ensure a smooth experience when navigating to different pages.
1315
>

quartz/components/ExplorerNode.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ export class FileNode {
4646
if (file.path[0] !== "index.md") {
4747
this.children.push(new FileNode(file.file.frontmatter!.title, file.file, this.depth + 1))
4848
} else {
49-
this.displayName = file.file.frontmatter!.title
49+
const title = file.file.frontmatter?.title
50+
if (title && title !== "index" && file.path[0] === "index.md") {
51+
this.displayName = title
52+
}
5053
}
5154
} else {
5255
const next = file.path[0]

0 commit comments

Comments
 (0)