Skip to content

Commit

Permalink
implement short_title for explorer sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
harryrichman committed Jul 19, 2024
1 parent 6375052 commit 9f5d13b
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions quartz/components/ExplorerNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export class FileNode {
constructor(slugSegment: string, displayName?: string, file?: QuartzPluginData, depth?: number) {
this.children = []
this.name = slugSegment
this.displayName = displayName ?? file?.frontmatter?.title ?? slugSegment
// use `short_title` if specified, otherwise use `title`
this.displayName = displayName ?? file?.frontmatter?.short_title ?? file?.frontmatter?.title ?? slugSegment
this.file = file ? clone(file) : null
this.depth = depth ?? 0
}
Expand All @@ -68,15 +69,11 @@ export class FileNode {
if (fileData.path.length === 1) {
if (nextSegment === "") {
// index case (we are the root and we just found index.md), set our data appropriately
const title = fileData.file.frontmatter?.short_title
if (title) {
// use `short_title` if specified, otherwise use `title`
const title = fileData.file.frontmatter?.short_title ?? fileData.file.frontmatter?.title
if (title && title !== "index") {
this.displayName = title
} else {
const title = fileData.file.frontmatter?.title
if (title && title !== "index") {
this.displayName = title
}
}
}
} else {
// direct child
this.children.push(new FileNode(nextSegment, undefined, fileData.file, this.depth + 1))
Expand Down

0 comments on commit 9f5d13b

Please sign in to comment.