Skip to content

Commit 2a06fad

Browse files
committed
Quartz sync: May 22, 2025, 2:16 PM
1 parent 5129c5f commit 2a06fad

File tree

8 files changed

+85
-43
lines changed

8 files changed

+85
-43
lines changed

content/Computer Science/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ aliases:
1313

1414
- Foundations & Theory
1515
- Data Structures
16-
- [[- Algorithms| 🗺️ - Algorithms]]
16+
- [[- Algorithms|🗺️ - Algorithms]]
1717
- Theory of Computation
1818
- Discrete Mathematics
1919
- Probability & Statistics
@@ -53,7 +53,7 @@ aliases:
5353
- Computer Vision
5454
- Application Development
5555
- Frontend Web Development (HTML, CSS, JavaScript, Frameworks)
56-
- [[- Frontend | 🗺️ - Frontend]]
56+
- [[- Frontend|🗺️ - Frontend]]
5757
- Backend Development (APIs, REST, GraphQL)
5858
- Mobile App Development (Android, iOS)
5959
- Desktop Application Development

content/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ comments: "false"
1313

1414
# MOC
1515
- [[About|About]]
16-
- [[- Computer Science | 🗺️ - Computer Science]]
17-
- [[- Algorithms| 🗺️ - Algorithms]]
18-
- [[- PS |🗺️ - PS]]
19-
- [[- Frontend| 🗺️ - Frontend]]
16+
- [[- Computer Science|🗺️ - Computer Science]]
17+
- [[- Algorithms|🗺️ - Algorithms]]
18+
- [[- PS|🗺️ - PS]]
19+
- [[- Frontend|🗺️ - Frontend]]
2020
- [[- Note Taking|🗺️ - Note Taking]]
21-
- [[- Philosophy | 🗺️ - Philosophy]]
21+
- [[- Philosophy|🗺️ - Philosophy]]
2222
- #moc
2323

2424
# Basic Guide

obsidian-content-sync.sh

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,38 @@ for ((i = 0; i < len; i++)); do
4848

4949
find "$pre_fix${output_path[$i]}" -type f -name "- *.md" | while read file; do
5050
dir=$(dirname "$file")
51-
mv "$file" "$dir/index.md"
51+
newfile="$dir/index.md"
52+
mv "$file" "$newfile"
53+
54+
filename=$(basename "$file" .md)
55+
if grep -q "^---" "$newfile"; then
56+
# YAML 끝나는 줄 찾기
57+
yaml_end=$(awk '/^---$/ { if (NR != 1) { print NR; exit } }' "$newfile")
58+
59+
# aliases: 있는지 확인
60+
if awk "NR<=${yaml_end}" "$newfile" | grep -q "^aliases:"; then
61+
# aliases: [] 형태면 [] 지우고 값 추가
62+
if awk "NR<=${yaml_end}" "$newfile" | grep -q "^aliases: *\[\]"; then
63+
sed -i '' "s/^aliases: *\[\]/aliases:\n - \"$filename\"/" "$newfile"
64+
else
65+
# 이미 aliases가 있으면 그 밑에 추가
66+
sed -i '' "/^aliases:/a\\
67+
- \"$filename\"
68+
" "$newfile"
69+
fi
70+
else
71+
# YAML 내부엔 있지만 aliases가 없을 때
72+
sed -i '' "${yaml_end}i\\
73+
aliases:\n - \"$filename\"
74+
" "$newfile"
75+
fi
76+
else
77+
# YAML 자체가 없을 경우 새로 추가
78+
tmp=$(mktemp)
79+
echo -e "---\naliases:\n - \"$filename\"\n---" >"$tmp"
80+
cat "$newfile" >>"$tmp"
81+
mv "$tmp" "$newfile"
82+
fi
83+
5284
done
5385
done

quartz/components/MarkmapViewer.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ function replaceMatches(str: string, regex: RegExp, replacer: (match: RegExpExec
2828
return accumulator
2929
}
3030

31-
3231
const wikilinkRegex = /\[\[(?<link>[^|\]]+)\|?((?<displayText>[^\]]+))?\]\]/g
3332

3433
function replacement(match) {
3534
const { link, displayText } = match.groups!
36-
const safeLink = link.trim().replace(/\s+/g, "-")
37-
// return `<a href=\"/${safeLink}\">${displayText || link}</a>`
38-
return `${displayText || link}`
35+
const safeLink = `quartz-${link.trim().replace(/\s+/g, "-")}`
36+
return `<a href=\"/${safeLink}\">${displayText || link}</a>`
3937
}
4038

4139
export const parseInternalLinks = recurseChildren(node => {
@@ -46,6 +44,7 @@ export const parseInternalLinks = recurseChildren(node => {
4644

4745
const MarkmapViewer: QuartzComponent = ({ displayClass, fileData }: QuartzComponentProps) => {
4846
const root = fileData.markmap
47+
4948
if (!root) {
5049
return (
5150
<div class={classNames(displayClass, "markmap")}>
@@ -94,15 +93,13 @@ const MarkmapViewer: QuartzComponent = ({ displayClass, fileData }: QuartzCompon
9493
<path d="M200-80q-50 0-85-35t-35-85q0-39 22.5-70t57.5-43v-87q0-50 35-85t85-35h160v-127q-35-12-57.5-43T360-760q0-50 35-85t85-35q50 0 85 35t35 85q0 39-22.5 70T520-647v127h160q50 0 85 35t35 85v87q35 12 57.5 43t22.5 70q0 50-35 85t-85 35q-50 0-85-35t-35-85q0-39 22.5-70t57.5-43v-87q0-17-11.5-28.5T680-440H520v127q35 12 57.5 43t22.5 70q0 50-35 85t-85 35q-50 0-85-35t-35-85q0-39 22.5-70t57.5-43v-127H280q-17 0-28.5 11.5T240-400v87q35 12 57.5 43t22.5 70q0 50-35 85t-85 35Zm0-80q17 0 28.5-11.5T240-200q0-17-11.5-28.5T200-240q-17 0-28.5 11.5T160-200q0 17 11.5 28.5T200-160Zm280 0q17 0 28.5-11.5T520-200q0-17-11.5-28.5T480-240q-17 0-28.5 11.5T440-200q0 17 11.5 28.5T480-160Zm280 0q17 0 28.5-11.5T800-200q0-17-11.5-28.5T760-240q-17 0-28.5 11.5T720-200q0 17 11.5 28.5T760-160ZM480-720q17 0 28.5-11.5T520-760q0-17-11.5-28.5T480-800q-17 0-28.5 11.5T440-760q0 17 11.5 28.5T480-720Z" />
9594
</svg>
9695
</button>
97-
<div class="global-markmap-outer">
98-
<div class="global-markmap-container">
96+
<div
97+
class="global-markmap-outer"
98+
data-markmap={encodeURIComponent(JSON.stringify(fileData.markmap))}
99+
>
100+
<div class="global-markmap-container" >
99101
<svg id="global-markmap" ></svg>
100102
<div id="global-markmap-toolbar"></div>
101-
<script
102-
id="global-markmap-data"
103-
type="application/json"
104-
dangerouslySetInnerHTML={{ __html: JSON.stringify(fileData.markmap) }}
105-
/>
106103
</div>
107104
</div>
108105
</div>

quartz/components/scripts/markmap.inline.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,22 @@ function renderGlobalMarkmap() {
1212

1313
const container = document.querySelector(".global-markmap-outer") as HTMLElement
1414
const svg = container.querySelector("#global-markmap") as SVGSVGElement
15-
const dataEl = container.querySelector("#global-markmap-data") as HTMLScriptElement
1615
const toolbarEl = container.querySelector("#global-markmap-toolbar") as HTMLElement
1716

18-
if (!container || !svg || !dataEl || !toolbarEl) {
17+
if (!container || !svg || !toolbarEl) {
1918
console.warn("❌ Markmap container or elements not found.")
2019
return
2120
}
2221

23-
// Reset previous content
2422
svg.innerHTML = ""
2523
toolbarEl.innerHTML = ""
2624

27-
const data = JSON.parse(dataEl.textContent ?? "{}")
25+
const raw = container.dataset.markmap
26+
if (!raw) {
27+
return
28+
}
29+
30+
const data = JSON.parse(decodeURIComponent(raw))
2831
const mm = Markmap.create(svg, markmapOptions, data)
2932
const toolbar = Toolbar.create(mm)
3033
toolbarEl.append(toolbar.render())

quartz/components/styles/markmap.scss

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,37 @@
3737
position: absolute;
3838
width: 100%;
3939
height: 100%;
40-
// display: block;
4140
z-index: 0;
4241
overflow: hidden;
42+
color: var(--darkgray);
43+
44+
.language-frontmatter {}
4345
}
4446

4547
#global-markmap-toolbar {
4648
position: absolute;
4749
bottom: 0;
4850
left: 0;
51+
right: 0;
4952
width: 100%;
5053
z-index: 10;
51-
padding: 0.5rem 1rem;
52-
background-color: var(--light);
53-
}
54-
55-
#global-markmap-toolbar,
56-
#global-markmap-toolbar>* {
57-
cursor: pointer;
58-
display: flex !important;
59-
flex-direction: row !important;
60-
justify-content: center;
61-
align-items: center;
62-
gap: 0.5rem;
54+
color: var(--darkgray);
6355

6456
.mm-toolbar-brand {
6557
display: none;
6658
}
59+
60+
.mm-toolbar {
61+
display: flex !important;
62+
flex-direction: row !important;
63+
justify-content: center;
64+
align-items: center;
65+
gap: 0.5rem;
66+
67+
.mm-toolbar-item {
68+
cursor: pointer;
69+
}
70+
}
6771
}
6872
}
6973
}

quartz/plugins/emitters/folderPage.tsx

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

quartz/plugins/transformers/frontmatter.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,31 @@ export const FrontMatter: QuartzTransformerPlugin<Partial<Options>> = (userOpts)
7878
data.title = file.stem ?? i18n(cfg.configuration.locale).propertyDefaults.title
7979
}
8080

81-
if (data.status == "🗺️") {
82-
data.title = "🗺️ " + data.title
83-
data.comments = false
84-
}
85-
8681
const tags = coerceToArray(coalesceAliases(data, ["tags", "tag"]))
8782
if (tags) {
8883
data.tags = [...new Set(tags.map((tag: string) => slugTag(tag)))]
8984
data.tags = data.tags.filter((tag: string) => tag !== "review")
9085
}
9186

92-
const aliases = coerceToArray(coalesceAliases(data, ["aliases", "alias"]))
87+
let aliases = coerceToArray(coalesceAliases(data, ["aliases", "alias"]))
88+
const quartz_alias = `quartz-${data.title.replace(/\s+/g, "-")}`
89+
if (!aliases) {
90+
aliases = [quartz_alias]
91+
} else {
92+
aliases.push(quartz_alias)
93+
}
94+
9395
if (aliases) {
9496
data.aliases = aliases // frontmatter
9597
file.data.aliases = getAliasSlugs(aliases)
9698
allSlugs.push(...file.data.aliases)
9799
}
98100

101+
if (data.status == "🗺️") {
102+
data.title = "🗺️ " + data.title
103+
data.comments = false
104+
}
105+
99106
if (data.permalink != null && data.permalink.toString() !== "") {
100107
data.permalink = data.permalink.toString() as FullSlug
101108
const aliases = file.data.aliases ?? []

0 commit comments

Comments
 (0)