Learning a new website creation system is challenging, so below, I’ll detail my process for figuring out how to customize different components.
Adding more Google Fonts
Process
I wanted the page title to display in a different font than all of the other headers. In quartz.config.ts, I first tried changing the header key-value pair to take multiple arguments:
Didn’t work. Then I tried adding another key-value pair:
Didn’t work. I knew that to embed Google fonts on a page, some embed code was needed. From the Google Fonts documentation, this would look something like:
This would go in the <head> section of an HTML file. I needed to figure out how the typograph parameters were getting read into the <head> section, so I looked in quartz/components and found Head.tsx. In this file I found:
From this, I learned that the googleFontHref() function was the driver. Looking at the top of Head.tsx, I saw that this function was in the file quartz/util/theme.ts:
Solution
Inside quartz/util/theme.ts, I modified the googleFontHref() function:
Original function
This required ensuring that siteTitle was a parameter in quartz.config.ts:
Inside quartz/util/theme.ts, I also modified the joinStyles() function to also include siteTitleFont as a new variable that could be referenced in style sheets:
I used siteTitleFont in quartz/styles/custom.scss:
Left menu bar navigation
I didn’t want to have Component.Explorer() so I created a static component that was just a list of links as NavMenu.tsx:
Changing date display
I wanted the metadata beneath the article title to look something like:
Last tended May 22, 2024 ╌ ❖ ╌ 1 min read
The “Last tended”, separator between the date and “X min read”, and the spacing between each of these components needed to be added.
There are three possible types (as found in quartz/plugins/transformers/lastmod.ts):
"created": corresponds to frontmatter date
"modified": corresponds to frontmatter lastmod or updated
"published": corresponds to frontmatter publishDate
I updated the defaultDateType in quartz.config.ts to be "modified".
In quartz/components/ContentMeta.tsx, I made the following changes:
Then I added the following to quartz/styles/custom.scss: