Skip to content

Commit ce0b294

Browse files
committed
Quartz sync: May 22, 2025, 6:31 PM
1 parent ee4c859 commit ce0b294

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

quartz/components/MarkmapViewer.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,34 @@ function replaceMatches(str: string, regex: RegExp, replacer: (match: RegExpExec
2929
return accumulator
3030
}
3131

32-
const wikilinkRegex = /(!)?\[\[(?<link>[^|\]]+)\|?(?<displayText>[^\]]*)\]\]/g
32+
const wikilinkRegex = /(!)?\[\[(?<link>[^|\]]+)\|?(?<displayText>[^\]]*)\]\]|#(?<tag>[A-Za-z0-9_-]+)(?=\s|$)/g
33+
3334
function replacement(currentPath: FullSlug) {
3435
return (match: RegExpExecArray) => {
35-
const { link, displayText } = match.groups!
36-
const isImage = /\.(png|jpg|jpeg|gif|svg)$/.test(link)
36+
const { link, displayText, tag } = match.groups!
37+
38+
if (link) {
3739

38-
if (isImage) {
39-
return `<img src="../../../${currentPath}/../attachments/${link}" alt="${displayText || link}" />`
40+
const isImage = /\.(png|jpg|jpeg|gif|svg)$/.test(link)
41+
42+
if (isImage) {
43+
return `<img src="../../../${currentPath}/../attachments/${link}" alt="${displayText || link}" />`
44+
}
45+
const safeLink = `quartz-${link.trim().replace(/\s+/g, "-")}`
46+
return `<a href="/${safeLink}" class="inner">${displayText || link}</a>`
47+
} else if (tag) {
48+
return `<a href="/tags/${tag}" class="hash-link">#${tag}</a>`
4049
}
41-
const safeLink = `quartz-${link.trim().replace(/\s+/g, "-")}`
42-
return `<a href="/${safeLink}" class="inner">${displayText || link}</a>`
4350
}
4451
}
4552

4653
export const parseInternalLinks = (slug: FullSlug) =>
4754
recurseChildren((node) => {
48-
node.content =
49-
replaceMatches(node.content, wikilinkRegex, replacement(slug))
55+
node.content = replaceMatches(
56+
node.content,
57+
wikilinkRegex,
58+
replacement(slug),
59+
)
5060
})
5161

5262

quartz/plugins/emitters/folderPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ function computeFolderInfo(
7474
defaultProcessedContent({
7575
slug: joinSegments(folder, "index") as FullSlug,
7676
frontmatter: {
77-
title: `${i18n(locale).pages.folderContent.folder}: ${lastSlash === -1 ? folder : unSluggify(folder.slice(folder.lastIndexOf("/")))}`,
77+
title: `📂 ${lastSlash === -1 ? folder : unSluggify(folder.slice(folder.lastIndexOf("/")))}`,
78+
// title: `📂 ${i18n(locale).pages.folderContent.folder}: ${lastSlash === -1 ? folder : unSluggify(folder.slice(folder.lastIndexOf("/")))}`,
7879
tags: [],
7980
comments: false,
8081
},

quartz/plugins/emitters/tagPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function computeTagInfo(
3434
const title =
3535
tag === "index"
3636
? i18n(locale).pages.tagContent.tagIndex
37-
: `${i18n(locale).pages.tagContent.tag}: ${tag}`
37+
: `🔖 ${i18n(locale).pages.tagContent.tag}: ${tag}`
3838
return [
3939
tag,
4040
defaultProcessedContent({

0 commit comments

Comments
 (0)