Skip to content

Commit 0d2d4b6

Browse files
committed
Quartz sync: May 21, 2025, 12:11 AM
1 parent 7b63050 commit 0d2d4b6

File tree

7 files changed

+60
-0
lines changed

7 files changed

+60
-0
lines changed

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@myriaddreamin/rehype-typst": "^0.6.0",
4141
"@napi-rs/simple-git": "0.1.19",
4242
"@tweenjs/tween.js": "^25.0.0",
43+
"@types/nprogress": "^0.2.3",
4344
"@webgpu/types": "^0.1.60",
4445
"ansi-truncate": "^1.2.0",
4546
"async-mutex": "^0.5.0",
@@ -63,6 +64,7 @@
6364
"mdast-util-to-string": "^4.0.0",
6465
"micromorph": "^0.4.5",
6566
"minimatch": "^10.0.1",
67+
"nprogress": "^0.2.0",
6668
"pixi.js": "^8.9.2",
6769
"preact": "^10.26.6",
6870
"preact-render-to-string": "^6.5.13",

quartz.layout.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const sharedPageComponents: SharedLayout = {
2020
// loading: 'lazy',
2121
}
2222
}),
23+
Component.ScrollProgress()
2324
],
2425
footer: Component.Footer({
2526
links: {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @ts-ignore
2+
import scrollProgressScript from "./scripts/scrollProgress.inline"
3+
import scrollStyle from "./styles/scrollProgress.scss"
4+
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
5+
6+
const ScrollProgress: QuartzComponent = ({ children }: QuartzComponentProps) => {
7+
return <div id="scroll-progress">{children}</div>
8+
}
9+
10+
ScrollProgress.afterDOMLoaded = scrollProgressScript
11+
ScrollProgress.css = scrollStyle
12+
13+
export default (() => ScrollProgress) satisfies QuartzComponentConstructor

quartz/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Breadcrumbs from "./Breadcrumbs"
2323
import Comments from "./Comments"
2424
import Flex from "./Flex"
2525
import ConditionalRender from "./ConditionalRender"
26+
import ScrollProgress from "./ScrollProgress"
2627

2728
export {
2829
ArticleTitle,
@@ -50,4 +51,5 @@ export {
5051
Comments,
5152
Flex,
5253
ConditionalRender,
54+
ScrollProgress,
5355
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import NProgress from "nprogress"
2+
3+
NProgress.configure({
4+
showSpinner: false,
5+
trickle: false
6+
})
7+
8+
let started = false
9+
10+
window.addEventListener("scroll", () => {
11+
if (!started) {
12+
NProgress.start()
13+
started = true
14+
}
15+
const scrollTop = window.scrollY
16+
const docHeight = document.documentElement.scrollHeight - window.innerHeight
17+
const progress = scrollTop / docHeight
18+
NProgress.set(progress)
19+
})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#nprogress .bar {
2+
background: var(--tertiary) !important;
3+
height: 4px !important;
4+
position: fixed;
5+
top: 0;
6+
left: 0;
7+
width: 100%;
8+
z-index: 9999;
9+
}

0 commit comments

Comments
 (0)