Skip to content

Commit 9f225d1

Browse files
committed
Quartz sync: Jun 11, 2025, 11:30 PM
1 parent 89edde8 commit 9f225d1

File tree

4 files changed

+74
-20
lines changed

4 files changed

+74
-20
lines changed

quartz.layout.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ export const defaultContentPageLayout: PageLayout = {
6363
{ Component: Component.Mindmap({ mode: "button", localOptions: {} }) },
6464
{
6565
Component: Component.Slide({
66-
tags: false
66+
tags: false,
67+
align: "center"
6768
})
6869
}
6970
],
@@ -126,7 +127,8 @@ export const defaultListPageLayout: PageLayout = {
126127
{ Component: Component.Mindmap({ mode: "button", localOptions: {} }) },
127128
{
128129
Component: Component.Slide({
129-
tags: false
130+
tags: false,
131+
align: "center"
130132
})
131133
}
132134
],

quartz/components/Slide.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export interface SlideOptions {
1919
},
2020
includePresenterNotes: boolean,
2121
tags: boolean,
22-
index: boolean
22+
index: boolean,
23+
align: "left" | "center"
2324
}
2425

2526
const defaultOptions: SlideOptions = {
@@ -37,6 +38,7 @@ const defaultOptions: SlideOptions = {
3738
includePresenterNotes: true,
3839
tags: true,
3940
index: true,
41+
align: "left"
4042
}
4143

4244
export default ((opts?: Partial<SlideOptions>) => {

quartz/components/scripts/slide.inline.ts

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,41 @@ function makeIndex() {
241241
`
242242
}
243243

244+
function appendCSS(option: SlideOptions) {
245+
if (document.getElementById("slide-align-style")) return
246+
247+
if (option.align === "center") {
248+
const styleElement = document.createElement("style")
249+
styleElement.id = "slide-align-style";
250+
251+
styleElement.textContent = `
252+
h1,
253+
h2,
254+
h3,
255+
h4,
256+
h5,
257+
h6 {
258+
justify-content: center;
259+
}
260+
261+
.remark-slide-content > *:not(.remark-slide-number) {
262+
align-self: center;
263+
max-width: 100%
264+
}
265+
266+
.remark-slide-content *:has(video),
267+
.remark-slide-content *:has(audio),
268+
.remark-slide-content *:has(iframe) {
269+
width: 100%;
270+
max-width: 95%;
271+
}
272+
273+
`;
274+
275+
document.head.appendChild(styleElement)
276+
}
277+
}
278+
244279
function appendRemark(option: SlideOptions) {
245280

246281
const header = `${document.querySelector(".page-header h1.article-title")?.outerHTML}`
@@ -291,6 +326,7 @@ function appendRemark(option: SlideOptions) {
291326
)
292327
}
293328
document.body.appendChild(script)
329+
appendCSS(option)
294330
}
295331

296332
function paramOption(defaultOption: SlideOptions) {
@@ -299,8 +335,15 @@ function paramOption(defaultOption: SlideOptions) {
299335
const getBool = (key: string, fallback = false) =>
300336
params.has(key) ? params.get(key)?.toLowerCase() === "true" : fallback
301337

302-
const ratioParam = params.get("ratio")
303-
const ratio = ratioParam === "4:3" ? "4:3" : "16:9"
338+
type Ratio = SlideOptions["ratio"]
339+
const validRatios: Ratio[] = ["4:3", "16:9"];
340+
const requestedRatio = params.get("ratio");
341+
const ratio: Ratio = validRatios.includes(requestedRatio as Ratio) ? requestedRatio as Ratio : defaultOption.ratio;
342+
343+
type Align = SlideOptions["align"]
344+
const validAlign: Align[] = ["left", "center"];
345+
const requestedAlign = params.get("align");
346+
const align: Align = validAlign.includes(requestedAlign as Align) ? requestedAlign as Align : defaultOption.align;
304347

305348
return ({
306349
...defaultOption,
@@ -320,6 +363,7 @@ function paramOption(defaultOption: SlideOptions) {
320363
includePresenterNotes: getBool("includePresenterNotes", defaultOption.includePresenterNotes),
321364
tags: getBool("tags", defaultOption.tags),
322365
index: getBool("index", defaultOption.index),
366+
align
323367
} as SlideOptions)
324368
}
325369

quartz/styles/custom.scss

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -390,22 +390,25 @@ hr {
390390
height: 100%;
391391
}
392392

393-
h1,
394-
h2,
395-
h3,
396-
h4,
397-
h5,
398-
h6 {
399-
position: sticky;
400-
top: 0;
401-
z-index: 1;
402-
background-color: color-mix(in srgb, var(--light) 80%, transparent);
403-
-webkit-backdrop-filter: blur(8px);
404-
backdrop-filter: blur(8px);
405-
padding-top: 1.5rem;
406-
}
407-
408393
@for $i from 1 through 6 {
394+
395+
h#{$i} {
396+
position: sticky;
397+
top: 0;
398+
z-index: 1;
399+
background-color: color-mix(in srgb, var(--light) 80%, transparent);
400+
-webkit-backdrop-filter: blur(8px);
401+
backdrop-filter: blur(8px);
402+
padding-top: 1.5rem;
403+
width: 100%;
404+
display: flex;
405+
align-items: baseline;
406+
407+
&>a {
408+
display: none;
409+
}
410+
}
411+
409412
h#{$i}:before {
410413
content: "H#{$i}";
411414
font-size: 0.5em;
@@ -481,12 +484,15 @@ hr {
481484

482485
img {
483486
margin: 0 0;
487+
max-width: 95%;
484488
}
485489

486490
video,
487491
audio,
488492
iframe {
489493
margin: 10px 0;
494+
width: 100%;
495+
max-width: 95%;
490496
}
491497

492498
.callout {

0 commit comments

Comments
 (0)