Skip to content

Commit 9f916be

Browse files
committed
2025-03-18 content update p2
1 parent 7ef522f commit 9f916be

4 files changed

+259
-68
lines changed

content/Quartz customization log.md

+120-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
date created: 2024-06-06T22:54
3-
date modified: 2025-03-18T16:24
3+
date modified: 2025-03-18T22:25
44
tags:
55
- recents-exclude
66
---
@@ -41,6 +41,124 @@ Misc things to remember:
4141
> - [Credits and Readmes](https://morrowind-modding.github.io/credits-and-readmes/#eilleens-online-everything-notebook) on the Morrowind Modding Wiki
4242
> - [Quartz Cheatsheet](https://abi-is-here.github.io/niwa/software/quartz/quartz-cheatsheet) by abi-is-here
4343
44+
## Emitting a second RSS feed
45+
46+
The normal one uses the default date type which for me is the modified date, which doesn't work well for me because I modify things all the time. So I'm emitting another one that sorts based on date created.
47+
48+
> [!code]- contentIndex
49+
> ```tsx title="contentIndex.tsx"
50+
> function generateCreatedRSSFeed(cfg: GlobalConfiguration, idx: ContentIndexMap, limit?: number): string {
51+
> const base = cfg.baseUrl ?? ""
52+
>
53+
> const createURLEntry = (slug: SimpleSlug, content: ContentDetails): string => `<item>
54+
> <title>${escapeHTML(content.title)}</title>
55+
> <link>https://${joinSegments(base, encodeURI(slug))}</link>
56+
> <guid>https://${joinSegments(base, encodeURI(slug))}</guid>
57+
> <description>${content.richContent ?? content.description}</description>
58+
> <pubDate>${content.date?.toUTCString()}</pubDate>
59+
> </item>`
60+
>
61+
> const items = Array.from(idx)
62+
> .sort(([_, f1], [__, f2]) => {
63+
> const date1 = _getDateCustom(cfg, f1, 'created')
64+
> const date2 = _getDateCustom(cfg, f2, 'created')
65+
> if (date1 && date2) {
66+
> return date2.getTime() - date1.getTime()
67+
> } else if (date1 && !date2) {
68+
> return -1
69+
> } else if (!date1 && date2) {
70+
> return 1
71+
> }
72+
>
73+
> return f1.title.localeCompare(f2.title)
74+
> })
75+
> .map(([slug, content]) => createURLEntry(simplifySlug(slug), content))
76+
> .slice(0, limit ?? idx.size)
77+
> .join("")
78+
>
79+
> return `<?xml version="1.0" encoding="UTF-8" ?>
80+
> <rss version="2.0">
81+
> <channel>
82+
> <title>${escapeHTML(cfg.pageTitle)}</title>
83+
> <link>https://${base}</link>
84+
> <description>${!!limit ? i18n(cfg.locale).pages.rss.lastFewNotes({ count: limit }) : i18n(cfg.locale).pages.rss.recentNotes} on ${escapeHTML(
85+
> cfg.pageTitle,
86+
> )}</description>
87+
> <generator>Quartz -- quartz.jzhao.xyz</generator>
88+
> ${items}
89+
> </channel>
90+
> </rss>`
91+
> }
92+
>
93+
> export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
94+
> opts = { ...defaultOptions, ...opts }
95+
> return {
96+
> name: "ContentIndex",
97+
> async getDependencyGraph(ctx, content, _resources) {
98+
> const graph = new DepGraph<FilePath>()
99+
>
100+
> for (const [_tree, file] of content) {
101+
> const sourcePath = file.data.filePath!
102+
>
103+
> graph.addEdge(
104+
> sourcePath,
105+
> joinSegments(ctx.argv.output, "static/contentIndex.json") as FilePath,
106+
> )
107+
> if (opts?.enableSiteMap) {
108+
> graph.addEdge(sourcePath, joinSegments(ctx.argv.output, "sitemap.xml") as FilePath)
109+
> }
110+
> if (opts?.enableRSS) {
111+
> graph.addEdge(sourcePath, joinSegments(ctx.argv.output, "index.xml") as FilePath)
112+
> graph.addEdge(sourcePath, joinSegments(ctx.argv.output, "index-created.xml") as FilePath)
113+
> }
114+
> }
115+
>
116+
> return graph
117+
> },
118+
> ...
119+
> if (opts?.enableRSS) {
120+
> yield write({
121+
> ctx,
122+
> content: generateRSSFeed(cfg, linkIndex, opts.rssLimit),
123+
> slug: (opts?.rssSlug ?? "index") as FullSlug,
124+
> ext: ".xml",
125+
> })
126+
> yield write({
127+
> ctx,
128+
> content: generateCreatedRSSFeed(cfg, linkIndex, opts.rssLimit),
129+
> slug: "index-created" as FullSlug,
130+
> ext: ".xml",
131+
> })
132+
> }
133+
> ...
134+
> externalResources: (ctx) => {
135+
> if (opts?.enableRSS) {
136+
> return {
137+
> additionalHead: [
138+
> <link
139+
> rel="alternate"
140+
> type="application/rss+xml"
141+
> title="RSS Feed"
142+
> href={`https://${ctx.cfg.configuration.baseUrl}/index.xml`}
143+
> />,
144+
> <link
145+
> rel="alternate"
146+
> type="application/rss+xml"
147+
> title="RSS Feed by Creation Time"
148+
> href={`https://${ctx.cfg.configuration.baseUrl}/index-created.xml`}
149+
> />,
150+
> ],
151+
> }
152+
> }
153+
> },
154+
> }
155+
> }
156+
> ```
157+
158+
## Upgrading to quartz 4.5
159+
160+
[[Upgrading to quartz 4.5]]
161+
44162
## Superscript styling
45163
46164
Sometimes a footnote will make the line spacing weird. [^1]
@@ -894,7 +1012,7 @@ async function mouseEnterHandler(
8941012
8951013
I made a new solution for footnotes, inspired by aarnphm's site (e.g. [Attribution parameter decomposition](https://aarnphm.xyz/thoughts/Attribution-parameter-decomposition#user-content-fnref-alias)) The idea is to take just the content of the footnote, instead of showing the entire popover hint, so there's no duplicate `#user-content-fn` id on the page to jump to.
8961014
897-
**In `popovers.inline.ts`,** add this to the top:
1015+
In `popovers.inline.ts`, add this to the top:
8981016
8991017
```ts
9001018
function isFootnoteLink(link: HTMLAnchorElement): boolean {

content/meta/All files chronologically modified.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tags:
66
- recents-exclude
77
title: All files chronologically modified
88
date created: 2024-07-20T22:16
9-
date modified: 2025-02-13T11:53
9+
date modified: 2025-03-18T22:33
1010
---
1111

1212
Table below made with the help of [Dataview](https://blacksmithgu.github.io/obsidian-dataview/) and [Obsidian Dataview Serializer](https://github.com/dsebastien/obsidian-dataview-serializer). The query:
@@ -36,10 +36,12 @@ Some hidden tags: anything with "exclude" basically
3636

3737
| File | Folder | Modified |
3838
| ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | ------------ |
39-
| [[meta/Code tester.md\|Code tester]] | meta | Mar 18, 2025 |
40-
| [[tbd/ACTUAL guide to a now playing widget.md\|ACTUAL guide to a now playing widget]] | tbd | Mar 18, 2025 |
4139
| [[Quartz customization log.md\|Quartz customization log]] | | Mar 18, 2025 |
40+
| [[meta/Upgrading to quartz 4.5.md\|Upgrading to quartz 4.5]] | meta | Mar 18, 2025 |
4241
| [[meta/Hiding tags from various components.md\|Hiding tags from various components]] | meta | Mar 18, 2025 |
42+
| [[tbd/passphrase encrypted page.md\|passphrase encrypted page]] | tbd | Mar 18, 2025 |
43+
| [[meta/Code tester.md\|Code tester]] | meta | Mar 18, 2025 |
44+
| [[tbd/ACTUAL guide to a now playing widget.md\|ACTUAL guide to a now playing widget]] | tbd | Mar 18, 2025 |
4345
| [[linux tech/My first ever raspberry pi!!!.md\|My first ever raspberry pi!!!]] | linux tech | Mar 18, 2025 |
4446
| [[tbd/Dataview reference.md\|Dataview reference]] | tbd | Mar 13, 2025 |
4547
| [[tbd/password locked page.md\|password locked page]] | tbd | Mar 6, 2025 |
@@ -83,6 +85,7 @@ Some hidden tags: anything with "exclude" basically
8385
| [[tbd/Untrack something that used to be tracked in git.md\|Untrack something that used to be tracked in git]] | tbd | Feb 2, 2025 |
8486
| [[hobbies/Squad Busters by Supercell.md\|Squad Busters by Supercell]] | hobbies | Feb 1, 2025 |
8587
| [[semiconductors and chips/Various areas or fields or categories or.md\|Various areas or fields or categories or]] | semiconductors and chips | Jan 18, 2025 |
88+
| [[meta/Upgrading to quartz 4.4.md\|Upgrading to quartz 4.4]] | meta | Jan 18, 2025 |
8689
| [[thoughts/How to cram for the GRE (2023).md\|How to cram for the GRE (2023)]] | thoughts | Jan 16, 2025 |
8790
| [[rgb tech/Installing yarn.md\|Installing yarn]] | rgb tech | Jan 5, 2025 |
8891
| [[linux tech/Ideas for what one can do with a home server.md\|Ideas for what one can do with a home server]] | linux tech | Jan 5, 2025 |
@@ -117,3 +120,4 @@ Some hidden tags: anything with "exclude" basically
117120
| [[semiconductors and chips/BIST - built-in self test.md\|BIST - built-in self test]] | semiconductors and chips | Jun 8, 2024 |
118121
| [[mac tech/adguard home.md\|adguard home]] | mac tech | Jun 8, 2024 |
119122
<!-- SerializedQuery END -->
123+
+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
date created: 2025-03-13T16:56
3+
date modified: 2025-03-18T22:21
4+
---
5+
6+
Can't say it was a pleasant experience... merge conflicts are not my passion...
7+
8+
[v4.4.1 upgrade w/ my modifications · fanteastick/quartz-test@81f7ecf · GitHub](https://github.com/fanteastick/quartz-test/commit/81f7ecf15bb55dd365f6dd58c2a0985ce5572442)
9+
10+
- ported over the old explorer and filenode as Old, just in case
11+
- floating buttons - since graph is a class now, the button click for global graph hits the first one in the list `globalGraphIcons[0].dispatchEvent(clickEvent);`
12+
- Explorer: strip folder icons, properly decide folder vs file so subfolders work
13+
- popover: if footnote, then only give the footnote content. if on the same page, don't give anything. and handle same page click.
14+
- toc: removing toc2, height 0 on collapse
15+
- setting correct icon for og images
16+
- removing `<hr/>` on renderpage
17+
- removing the text on the search bar
18+
- add ᯽ to toc
19+
- properly skip contentpage emitting of tag pages and folder pages `if (file.data.slug?.endsWith("/index") || file.data.slug?.includes("tags/")) {`
20+
- reduce `$topSpacing: 4rem;`
21+
- og needs to ignore -exclude in the tags
22+
23+
## Surrendered and started using the built-in explorer
24+
25+
also, what if i don't want the explorer in the left corner? huh?
26+
27+
Oh my goodness thank you copilot! subfolder nodes
28+
29+
```ts title="explorer.inline.ts"
30+
for (const child of node.children) {
31+
const childNode = child.children.length > 0
32+
? createFolderNode(currentSlug, child, opts)
33+
: createFileNode(currentSlug, child)
34+
ul.appendChild(childNode)
35+
}
36+
```
37+
38+
Explorerconfig:
39+
40+
```ts title="quartz.layout.ts"
41+
const explorerConfig = {
42+
filterFn: (node: FileTrieNode) => !(node.data?.tags.includes("explorer-exclude") === true),
43+
mapFn: (node: FileTrieNode) => {
44+
// dont change name of root node
45+
if (!node.isFolder) {
46+
// set emoji for file/folder
47+
node.displayName = "⊹ ࣪" + node.displayName
48+
}
49+
},
50+
}
51+
```
52+
53+
## Graph - radial mode??? it got all messed up
54+
55+
I fixed it similar to last time: [[Quartz customization log#Radial graph shifting and titles]]
56+
57+
## Permalinks
58+
59+
They're getting skipped because I don't use aliases...
60+
61+
```ts title="frontmatter.ts"
62+
const aliases = coerceToArray(coalesceAliases(data, ["aliases", "alias"]))
63+
const permalink = data.permalink
64+
65+
if (aliases || permalink) {
66+
if (aliases) {
67+
data.aliases = aliases // frontmatter
68+
}
69+
const slugs = (file.data.aliases = getAliasSlugs(aliases ?? [], argv, file))
70+
allSlugs.push(...slugs)
71+
}
72+
```
73+
74+
```ts title="aliases.ts"
75+
export const AliasRedirects: QuartzEmitterPlugin = () => ({
76+
name: "AliasRedirects",
77+
async getDependencyGraph(ctx, content, _resources) {
78+
const graph = new DepGraph<FilePath>()
79+
80+
const { argv } = ctx
81+
for (const [_tree, file] of content) {
82+
const aliases = file.data.frontmatter?.aliases ?? []
83+
const permalink = file.data.frontmatter?.permalink
84+
const slugs = getAliasSlugs(aliases, argv, file)
85+
86+
if (permalink) {
87+
slugs.push(permalink as FullSlug)
88+
}
89+
90+
...
91+
92+
async *emit(ctx, content, _resources) {
93+
for (const [_tree, file] of content) {
94+
const ogSlug = simplifySlug(file.data.slug!)
95+
const aliases = file.data.aliases ?? []
96+
const permalink = file.data.frontmatter?.permalink
97+
98+
const slugs = [...aliases]
99+
if (permalink) {
100+
slugs.push(permalink as FullSlug)
101+
}
102+
```
103+
104+
## Open Graph images for folder and tag pages
105+
106+
%% og images %%
107+
108+
```tsx title="ogImage.tsx"
109+
const title =
110+
(vfile.data.frontmatter?.title ?? i18n(cfg.locale).propertyDefaults.title) + titleSuffix
111+
let description =
112+
vfile.data.frontmatter?.socialDescription ??
113+
vfile.data.frontmatter?.description ??
114+
unescapeHTML(
115+
vfile.data.description?.trim() ?? i18n(cfg.locale).propertyDefaults.description,
116+
)
117+
118+
// Set default description for folder and tag pages if none is provided
119+
if (!description) {
120+
if (vfile.stem?.startsWith("tags/")) {
121+
description = "This is a list of all the pages with this tag.";
122+
} else if (vfile.stem === "index") {
123+
description = "This is a list of all the pages in this folder.";
124+
}
125+
}
126+
```
127+
## later consider
128+
129+
messing with the prenav event:
130+
131+
- fixing the music thing abcjs
132+
- fancytext loader

content/tbd/Upgrading to quartz 4.5.md

-63
This file was deleted.

0 commit comments

Comments
 (0)