fix: Fix `Backlinks` not applying the display class (#519)
* fix: Fix `Backlinks` not applying the display class
Fix #518
* fix: Apply `displayClass` to all layout components
* refactor: Use same style
* fix: Remove `undefined` class using coalescing operator
| | |
| | | import { QuartzComponentConstructor, QuartzComponentProps } from "./types" |
| | | |
| | | function ArticleTitle({ fileData }: QuartzComponentProps) { |
| | | function ArticleTitle({ fileData, displayClass }: QuartzComponentProps) { |
| | | const title = fileData.frontmatter?.title |
| | | if (title) { |
| | | return <h1 class="article-title">{title}</h1> |
| | | return <h1 class={`article-title ${displayClass ?? ""}`}>{title}</h1> |
| | | } else { |
| | | return null |
| | | } |
| | |
| | | import style from "./styles/backlinks.scss" |
| | | import { resolveRelative, simplifySlug } from "../util/path" |
| | | |
| | | function Backlinks({ fileData, allFiles }: QuartzComponentProps) { |
| | | function Backlinks({ fileData, allFiles, displayClass }: QuartzComponentProps) { |
| | | const slug = simplifySlug(fileData.slug!) |
| | | const backlinkFiles = allFiles.filter((file) => file.links?.includes(slug)) |
| | | return ( |
| | | <div class="backlinks"> |
| | | <div class={`backlinks ${displayClass ?? ""}`}> |
| | | <h3>Backlinks</h3> |
| | | <ul class="overflow"> |
| | | {backlinkFiles.length > 0 ? ( |
| | |
| | | // Merge options with defaults |
| | | const options: BreadcrumbOptions = { ...defaultOptions, ...opts } |
| | | |
| | | function Breadcrumbs({ fileData, allFiles }: QuartzComponentProps) { |
| | | function Breadcrumbs({ fileData, allFiles, displayClass }: QuartzComponentProps) { |
| | | // Hide crumbs on root if enabled |
| | | if (options.hideOnRoot && fileData.slug === "index") { |
| | | return <></> |
| | |
| | | } |
| | | } |
| | | return ( |
| | | <nav class="breadcrumb-container" aria-label="breadcrumbs"> |
| | | <nav class={`breadcrumb-container ${displayClass ?? ""}`} aria-label="breadcrumbs"> |
| | | {crumbs.map((crumb, index) => ( |
| | | <div class="breadcrumb-element"> |
| | | <a href={crumb.path}>{crumb.displayName}</a> |
| | |
| | | import readingTime from "reading-time" |
| | | |
| | | export default (() => { |
| | | function ContentMetadata({ cfg, fileData }: QuartzComponentProps) { |
| | | function ContentMetadata({ cfg, fileData, displayClass }: QuartzComponentProps) { |
| | | const text = fileData.text |
| | | if (text) { |
| | | const segments: string[] = [] |
| | |
| | | } |
| | | |
| | | segments.push(timeTaken) |
| | | return <p class="content-meta">{segments.join(", ")}</p> |
| | | return <p class={`content-meta ${displayClass ?? ""}`}>{segments.join(", ")}</p> |
| | | } else { |
| | | return null |
| | | } |
| | |
| | | // see: https://v8.dev/features/modules#defer |
| | | import darkmodeScript from "./scripts/darkmode.inline" |
| | | import styles from "./styles/darkmode.scss" |
| | | import { QuartzComponentConstructor } from "./types" |
| | | import { QuartzComponentConstructor, QuartzComponentProps } from "./types" |
| | | |
| | | function Darkmode() { |
| | | function Darkmode({ displayClass }: QuartzComponentProps) { |
| | | return ( |
| | | <div class="darkmode"> |
| | | <div class={`darkmode ${displayClass ?? ""}`}> |
| | | <input class="toggle" id="darkmode-toggle" type="checkbox" tabIndex={-1} /> |
| | | <label id="toggle-label-light" for="darkmode-toggle" tabIndex={-1}> |
| | | <svg |
| | |
| | | function Explorer({ allFiles, displayClass, fileData }: QuartzComponentProps) { |
| | | constructFileTree(allFiles) |
| | | return ( |
| | | <div class={`explorer ${displayClass}`}> |
| | | <div class={`explorer ${displayClass ?? ""}`}> |
| | | <button |
| | | type="button" |
| | | id="explorer" |
| | |
| | | import { QuartzComponentConstructor } from "./types" |
| | | import { QuartzComponentConstructor, QuartzComponentProps } from "./types" |
| | | import style from "./styles/footer.scss" |
| | | import { version } from "../../package.json" |
| | | |
| | |
| | | } |
| | | |
| | | export default ((opts?: Options) => { |
| | | function Footer() { |
| | | function Footer({ displayClass }: QuartzComponentProps) { |
| | | const year = new Date().getFullYear() |
| | | const links = opts?.links ?? [] |
| | | return ( |
| | | <footer> |
| | | <footer class={`${displayClass ?? ""}`}> |
| | | <hr /> |
| | | <p> |
| | | Created with <a href="https://quartz.jzhao.xyz/">Quartz v{version}</a>, © {year} |
| | |
| | | import { QuartzComponentConstructor } from "./types" |
| | | import { QuartzComponentConstructor, QuartzComponentProps } from "./types" |
| | | // @ts-ignore |
| | | import script from "./scripts/graph.inline" |
| | | import style from "./styles/graph.scss" |
| | |
| | | } |
| | | |
| | | export default ((opts?: GraphOptions) => { |
| | | function Graph() { |
| | | function Graph({ displayClass }: QuartzComponentProps) { |
| | | const localGraph = { ...defaultOptions.localGraph, ...opts?.localGraph } |
| | | const globalGraph = { ...defaultOptions.globalGraph, ...opts?.globalGraph } |
| | | return ( |
| | | <div class="graph"> |
| | | <div class={`graph ${displayClass ?? ""}`}> |
| | | <h3>Graph View</h3> |
| | | <div class="graph-outer"> |
| | | <div id="graph-container" data-cfg={JSON.stringify(localGraph)}></div> |
| | |
| | | import { pathToRoot } from "../util/path" |
| | | import { QuartzComponentConstructor, QuartzComponentProps } from "./types" |
| | | |
| | | function PageTitle({ fileData, cfg }: QuartzComponentProps) { |
| | | function PageTitle({ fileData, cfg, displayClass }: QuartzComponentProps) { |
| | | const title = cfg?.pageTitle ?? "Untitled Quartz" |
| | | const baseDir = pathToRoot(fileData.slug!) |
| | | return ( |
| | | <h1 class="page-title"> |
| | | <h1 class={`page-title ${displayClass ?? ""}`}> |
| | | <a href={baseDir}>{title}</a> |
| | | </h1> |
| | | ) |
| | |
| | | }) |
| | | |
| | | export default ((userOpts?: Partial<Options>) => { |
| | | function RecentNotes(props: QuartzComponentProps) { |
| | | const { allFiles, fileData, displayClass, cfg } = props |
| | | function RecentNotes({ allFiles, fileData, displayClass, cfg }: QuartzComponentProps) { |
| | | const opts = { ...defaultOptions(cfg), ...userOpts } |
| | | const pages = allFiles.filter(opts.filter).sort(opts.sort) |
| | | const remaining = Math.max(0, pages.length - opts.limit) |
| | | return ( |
| | | <div class={`recent-notes ${displayClass}`}> |
| | | <div class={`recent-notes ${displayClass ?? ""}`}> |
| | | <h3>{opts.title}</h3> |
| | | <ul class="recent-ul"> |
| | | {pages.slice(0, opts.limit).map((page) => { |
| | |
| | | import { QuartzComponentConstructor } from "./types" |
| | | import { QuartzComponentConstructor, QuartzComponentProps } from "./types" |
| | | import style from "./styles/search.scss" |
| | | // @ts-ignore |
| | | import script from "./scripts/search.inline" |
| | | |
| | | export default (() => { |
| | | function Search() { |
| | | function Search({ displayClass }: QuartzComponentProps) { |
| | | return ( |
| | | <div class="search"> |
| | | <div class={`search ${displayClass ?? ""}`}> |
| | | <div id="search-icon"> |
| | | <p>Search</p> |
| | | <div></div> |
| | |
| | | import { QuartzComponentConstructor, QuartzComponentProps } from "./types" |
| | | |
| | | function Spacer({ displayClass }: QuartzComponentProps) { |
| | | const className = displayClass ? `spacer ${displayClass}` : "spacer" |
| | | return <div class={className}></div> |
| | | return <div class={`spacer ${displayClass ?? ""}`}></div> |
| | | } |
| | | |
| | | export default (() => Spacer) satisfies QuartzComponentConstructor |
| | |
| | | } |
| | | |
| | | return ( |
| | | <div class={`toc ${displayClass}`}> |
| | | <div class={`toc ${displayClass ?? ""}`}> |
| | | <button type="button" id="toc"> |
| | | <h3>Table of Contents</h3> |
| | | <svg |
| | |
| | | import { pathToRoot, slugTag } from "../util/path" |
| | | import { QuartzComponentConstructor, QuartzComponentProps } from "./types" |
| | | |
| | | function TagList({ fileData }: QuartzComponentProps) { |
| | | function TagList({ fileData, displayClass }: QuartzComponentProps) { |
| | | const tags = fileData.frontmatter?.tags |
| | | const baseDir = pathToRoot(fileData.slug!) |
| | | if (tags && tags.length > 0) { |
| | | return ( |
| | | <ul class="tags"> |
| | | <ul class={`tags ${displayClass ?? ""}`}> |
| | | {tags.map((tag) => { |
| | | const display = `#${tag}` |
| | | const linkDest = baseDir + `/tags/${slugTag(tag)}` |