Compare commits
380 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
696403d3fa | ||
|
|
2c30abe457 | ||
|
|
80c3196fee | ||
|
|
d9159e0ac9 | ||
|
|
c005fe4408 | ||
|
|
580c1bd608 | ||
|
|
270a5dc14a | ||
|
|
bfa938cc62 | ||
|
|
e3c50caf13 | ||
|
|
ca08ec1ae7 | ||
|
|
2718ab9019 | ||
|
|
87b803790c | ||
|
|
e59181c3aa | ||
|
|
b00198b888 | ||
|
|
9e3e711646 | ||
|
|
a8001e9554 | ||
|
|
dd940a007c | ||
|
|
a71e17919b | ||
|
|
aca0c330e7 | ||
|
|
dcaf806190 | ||
|
|
23df17233d | ||
|
|
8d33608808 | ||
|
|
d618a4e3f3 | ||
|
|
9c8fec06d2 | ||
|
|
1cd8e7f0d5 | ||
|
|
5480269d38 | ||
|
|
a201105442 | ||
|
|
cc9704becc | ||
|
|
6d195fd40a | ||
|
|
2213424195 | ||
|
|
5b13ff2199 | ||
|
|
5a39719898 | ||
|
|
3c8ccde624 | ||
|
|
c97fd7089a | ||
|
|
2acfa0fa23 | ||
|
|
f6f417a505 | ||
|
|
a3b6201365 | ||
|
|
a1162b978a | ||
|
|
c6f10b44f6 | ||
|
|
b050162f82 | ||
|
|
6d350500f1 | ||
|
|
9b47279fe6 | ||
|
|
4901472aa8 | ||
|
|
28fe9b2095 | ||
|
|
9a0d919a3b | ||
|
|
598741a571 | ||
|
|
29c533a265 | ||
|
|
1a02642469 | ||
|
|
5794405974 | ||
|
|
59d5a0ed3a | ||
|
|
dd6bd498db | ||
|
|
04423d4931 | ||
|
|
be846e6a5f | ||
|
|
32ec711767 | ||
|
|
91189dfd2f | ||
|
|
fbc45548f7 | ||
|
|
7be47742a6 | ||
|
|
4e4930ef9c | ||
|
|
01943ff5a0 | ||
|
|
8cf3e3001f | ||
|
|
992ac00f7c | ||
|
|
09f8670db7 | ||
|
|
7e828252bb | ||
|
|
c90dbacab0 | ||
|
|
b7a945e034 | ||
|
|
dc3323b574 | ||
|
|
c98ef7e89f | ||
|
|
2e6a675edd | ||
|
|
e3162f7a7e | ||
|
|
9466c145b1 | ||
|
|
a934397961 | ||
|
|
b2752e7262 | ||
|
|
d9e36e60d1 | ||
|
|
46adb35966 | ||
|
|
e1c9eabef4 | ||
|
|
d88e43010a | ||
|
|
ef72f1bf70 | ||
|
|
7d4bed64a9 | ||
|
|
99011cb1b0 | ||
|
|
c91cf97f99 | ||
|
|
05e6f05a50 | ||
|
|
7533d504dc | ||
|
|
69a0ddf733 | ||
|
|
a582505daf | ||
|
|
965f9e123c | ||
|
|
ff9e60a7fc | ||
|
|
367bb0e6ce | ||
|
|
8141cb1587 | ||
|
|
5ccc2dcbba | ||
|
|
11c98f5600 | ||
|
|
5a5ef670fe | ||
|
|
285c0e9768 | ||
|
|
adb326c933 | ||
|
|
0c4281eb53 | ||
|
|
7ac94e1d84 | ||
|
|
e1d754ef79 | ||
|
|
a727b57e46 | ||
|
|
1a4cfa606f | ||
|
|
410001b942 | ||
|
|
f24a147276 | ||
|
|
137d55eb1b | ||
|
|
9188939b1f | ||
|
|
92676d746e | ||
|
|
1893196939 | ||
|
|
1ab9c91df1 | ||
|
|
0ad9111388 | ||
|
|
cbeef5541f | ||
|
|
0f04f1262c | ||
|
|
31e0b7c6f8 | ||
|
|
a6b2967df8 | ||
|
|
f84a6554f6 | ||
|
|
1d5b6f58d8 | ||
|
|
74f8c13598 | ||
|
|
56ba2f4fa7 | ||
|
|
314a88d5c6 | ||
|
|
a53772bbd1 | ||
|
|
1915a198d9 | ||
|
|
1d2dc167f4 | ||
|
|
3ef2a24f4b | ||
|
|
d98a3a088a | ||
|
|
ad52d09567 | ||
|
|
9f701e5045 | ||
|
|
67e1beea70 | ||
|
|
3aa11357aa | ||
|
|
b3a02909ba | ||
|
|
1dc208356a | ||
|
|
3d0ba32070 | ||
|
|
c5d97db000 | ||
|
|
0d1f15d37c | ||
|
|
11c23a137a | ||
|
|
8a95c865c8 | ||
|
|
fe4b039b60 | ||
|
|
497d51973a | ||
|
|
66d7dd8677 | ||
|
|
313cef60ee | ||
|
|
af14ca7c4f | ||
|
|
e06f681ce7 | ||
|
|
62906eebd3 | ||
|
|
9cd072bfc3 | ||
|
|
319b4497bc | ||
|
|
b0c079f24a | ||
|
|
1b122a1da0 | ||
|
|
b8c46ba81a | ||
|
|
1416f62a47 | ||
|
|
8889ab63eb | ||
|
|
5eec1e98e6 | ||
|
|
a7a0dcad22 | ||
|
|
921f45cf70 | ||
|
|
90c187587f | ||
|
|
08e20a7006 | ||
|
|
9e32016508 | ||
|
|
8a050c0be0 | ||
|
|
0aacd8ed2e | ||
|
|
7d7e334976 | ||
|
|
9cefcd0dd1 | ||
|
|
4aaeb768d8 | ||
|
|
743ef712d5 | ||
|
|
9a6e4e2f80 | ||
|
|
14cb50de9b | ||
|
|
dad0ae4e3f | ||
|
|
9c060f3cf2 | ||
|
|
16a9caa555 | ||
|
|
b1c60b8833 | ||
|
|
50a78bafa5 | ||
|
|
6ea359e55e | ||
|
|
cd3bb25626 | ||
|
|
eb9bbd1666 | ||
|
|
c36551310d | ||
|
|
6215dd5565 | ||
|
|
c89c76b40a | ||
|
|
a145e320d0 | ||
|
|
082cbb74c3 | ||
|
|
93b2481261 | ||
|
|
d2414b3903 | ||
|
|
01fc26d2c0 | ||
|
|
84a9be65ce | ||
|
|
6715079a89 | ||
|
|
d613a3d2f2 | ||
|
|
9b75faafea | ||
|
|
5a26b582ed | ||
|
|
4e2aea8a5a | ||
|
|
40f039983c | ||
|
|
3b988aec61 | ||
|
|
bca74623a3 | ||
|
|
4c9e860150 | ||
|
|
46b63b68bf | ||
|
|
c4cd84dcc8 | ||
|
|
2be9c096a1 | ||
|
|
f913332862 | ||
|
|
647c125525 | ||
|
|
3b74453fe6 | ||
|
|
6b499ed90c | ||
|
|
437d65c847 | ||
|
|
7c5709b660 | ||
|
|
21e1921822 | ||
|
|
e47c29d2fd | ||
|
|
a5f2f874f7 | ||
|
|
eb23cbe8da | ||
|
|
cb68069d45 | ||
|
|
d27c292736 | ||
|
|
0ee103a514 | ||
|
|
c5f0b69a52 | ||
|
|
323167a001 | ||
|
|
3b5ed813f5 | ||
|
|
195fc5134c | ||
|
|
e89c395f7c | ||
|
|
2db735a150 | ||
|
|
39eebca3cf | ||
|
|
9acaa1c8ac | ||
|
|
27a41abb62 | ||
|
|
12904ab796 | ||
|
|
4bbcc0c50a | ||
|
|
3938904cd0 | ||
|
|
407fad384c | ||
|
|
ca3943b500 | ||
|
|
6c4ed249ba | ||
|
|
563ab4aaaf | ||
|
|
1c2d542138 | ||
|
|
e864740df7 | ||
|
|
efed544df1 | ||
|
|
3d156b8497 | ||
|
|
38361aaf48 | ||
|
|
f3e07fd51c | ||
|
|
d79911fa79 | ||
|
|
963c7c8654 | ||
|
|
3728929ee6 | ||
|
|
1224c7d32f | ||
|
|
bf1c9d1791 | ||
|
|
6264f5685c | ||
|
|
e1a9661be7 | ||
|
|
bc95332fce | ||
|
|
740172acb6 | ||
|
|
34fde07cf8 | ||
|
|
e688eeeaff | ||
|
|
5749fbbd75 | ||
|
|
5f10df4d05 | ||
|
|
03f23e5054 | ||
|
|
b9ee44aad7 | ||
|
|
87f2b0c327 | ||
|
|
805d9e3226 | ||
|
|
5fcba1bfaf | ||
|
|
942c35183a | ||
|
|
b37c408985 | ||
|
|
f37dbe1a59 | ||
|
|
247625c4f5 | ||
|
|
4b407e786f | ||
|
|
9cabf2b416 | ||
|
|
965425d54d | ||
|
|
ea92ed4f45 | ||
|
|
596e06ab0e | ||
|
|
c95f1d2336 | ||
|
|
b7793bd856 | ||
|
|
ef375d265d | ||
|
|
2154d36d99 | ||
|
|
3eda53cac7 | ||
|
|
4eeacb7fbf | ||
|
|
6245935c8c | ||
|
|
e20dee2850 | ||
|
|
af1fdaac0a | ||
|
|
5926d3f803 | ||
|
|
e8277d017e | ||
|
|
b053d354b6 | ||
|
|
dbe12c0d34 | ||
|
|
21e75acc8d | ||
|
|
f7bd2137ec | ||
|
|
3faf2ff6f5 | ||
|
|
1d94e9c303 | ||
|
|
48e16c943a | ||
|
|
cc5913b75c | ||
|
|
265faef4e8 | ||
|
|
541b470cfc | ||
|
|
0a3be96dd6 | ||
|
|
3cb9392a7a | ||
|
|
569ee74633 | ||
|
|
42640bceb5 | ||
|
|
3e14b2b89b | ||
|
|
81d00fc9c0 | ||
|
|
a12d76afdb | ||
|
|
19e127f6ad | ||
|
|
0472daa003 | ||
|
|
63d51a8cc5 | ||
|
|
9032717486 | ||
|
|
3968b850c2 | ||
|
|
688c5484a9 | ||
|
|
09038f1604 | ||
|
|
244801af65 | ||
|
|
73a5ec87f1 | ||
|
|
520acbbf6f | ||
|
|
0b9f79e1b7 | ||
|
|
94fbf5b066 | ||
|
|
3e0e06ff8a | ||
|
|
e57984dafc | ||
|
|
9ff4626d25 | ||
|
|
a99e854d1e | ||
|
|
77d6d9623f | ||
|
|
9c726efa33 | ||
|
|
81a4e20236 | ||
|
|
cf1b3f270b | ||
|
|
a655cec9f6 | ||
|
|
a97e72f219 | ||
|
|
e3cfe1f22f | ||
|
|
535af55ec8 | ||
|
|
3c4d54352d | ||
|
|
67f3614f3d | ||
|
|
438ea6d73b | ||
|
|
d03fdc235a | ||
|
|
aee9145691 | ||
|
|
a37c7775e7 | ||
|
|
e763e1969e | ||
|
|
6a019dae13 | ||
|
|
4d73b8289d | ||
|
|
8010093df7 | ||
|
|
1f032f538b | ||
|
|
83bdcd58e6 | ||
|
|
dd82ab8d79 | ||
|
|
561dafce5f | ||
|
|
5ec61468d5 | ||
|
|
aa4f5294a3 | ||
|
|
fafe50b0c5 | ||
|
|
8f13a38b5a | ||
|
|
d75928ad5c | ||
|
|
0a2b52f618 | ||
|
|
8437d9da72 | ||
|
|
70d86ff096 | ||
|
|
6efc4dd724 | ||
|
|
85a737b4ee | ||
|
|
de6f469011 | ||
|
|
668640d641 | ||
|
|
8007ec0f82 | ||
|
|
7e22c38f8e | ||
|
|
daa8796554 | ||
|
|
91f0a2abb2 | ||
|
|
38d9d52137 | ||
|
|
253497cad4 | ||
|
|
4691369abf | ||
|
|
7164857f6e | ||
|
|
47024022e8 | ||
|
|
b98e4be665 | ||
|
|
8be51a0504 | ||
|
|
92cc23dc45 | ||
|
|
097abc3cda | ||
|
|
a00324ddfd | ||
|
|
9fff6d7d0d | ||
|
|
0f5a9d7b66 | ||
|
|
b4236e5142 | ||
|
|
6e0c102970 | ||
|
|
94a54698ab | ||
|
|
2e9a0c21db | ||
|
|
b30a200bd4 | ||
|
|
6d59aa8201 | ||
|
|
141dd3b51f | ||
|
|
3d4a94dda3 | ||
|
|
ba6c7a73d1 | ||
|
|
f44e4d25e6 | ||
|
|
001c166825 | ||
|
|
e13cafe070 | ||
|
|
0ca8a2ac7c | ||
|
|
a506cedd7a | ||
|
|
5163504517 | ||
|
|
73a890ab12 | ||
|
|
83ab39c7bd | ||
|
|
059dd1260e | ||
|
|
a13d8e84b2 | ||
|
|
cec3662c74 | ||
|
|
bcb5b2df09 | ||
|
|
bd05950c2d | ||
|
|
2a7e61ae2a | ||
|
|
566f3cf9f8 | ||
|
|
018c6358c4 | ||
|
|
1c42b6365c | ||
|
|
f200a0be22 | ||
|
|
b9dee0775c | ||
|
|
66a5855fad | ||
|
|
4957eaa2d0 | ||
|
|
6b90d03ca6 | ||
|
|
d6e79d1ea6 | ||
|
|
2f10da7766 | ||
|
|
67647d9167 | ||
|
|
b88d3d292b | ||
|
|
c53fd5b56f |
19
.github/dependabot.yml
vendored
@@ -1,11 +1,20 @@
|
|||||||
# To get started with Dependabot version updates, you'll need to specify which
|
|
||||||
# package ecosystems to update and where the package manifests are located.
|
|
||||||
# Please see the documentation for all configuration options:
|
|
||||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
||||||
|
|
||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
- package-ecosystem: "npm"
|
- package-ecosystem: "npm"
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: "weekly"
|
||||||
|
groups:
|
||||||
|
production-dependencies:
|
||||||
|
applies-to: "version-updates"
|
||||||
|
patterns:
|
||||||
|
- "*"
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
groups:
|
||||||
|
ci-dependencies:
|
||||||
|
applies-to: "version-updates"
|
||||||
|
patterns:
|
||||||
|
- "*"
|
||||||
|
|||||||
27
.github/workflows/ci.yaml
vendored
@@ -7,6 +7,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- v4
|
- v4
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
build-and-test:
|
||||||
@@ -18,17 +19,17 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 20
|
||||||
|
|
||||||
- name: Cache dependencies
|
- name: Cache dependencies
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.npm
|
path: ~/.npm
|
||||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||||
@@ -44,13 +45,25 @@ jobs:
|
|||||||
run: npm test
|
run: npm test
|
||||||
|
|
||||||
- name: Ensure Quartz builds, check bundle info
|
- name: Ensure Quartz builds, check bundle info
|
||||||
run: npx quartz build --bundleInfo
|
run: npx quartz build --bundleInfo -d docs
|
||||||
|
|
||||||
|
publish-tag:
|
||||||
|
if: ${{ github.repository == 'jackyzha0/quartz' && github.ref == 'refs/heads/v4' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
- name: Get package version
|
- name: Get package version
|
||||||
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
|
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Create release tag
|
- name: Create release tag
|
||||||
uses: pkgdeps/git-tag-action@v2
|
uses: pkgdeps/git-tag-action@v3
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
github_repo: ${{ github.repository }}
|
github_repo: ${{ github.repository }}
|
||||||
|
|||||||
88
.github/workflows/docker-build-push.yaml
vendored
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
name: Docker build & push image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [v4]
|
||||||
|
tags: ["v*"]
|
||||||
|
pull_request:
|
||||||
|
branches: [v4]
|
||||||
|
paths:
|
||||||
|
- .github/workflows/docker-build-push.yaml
|
||||||
|
- quartz/**
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
if: ${{ github.repository == 'jackyzha0/quartz' }} # Comment this out if you want to publish your own images on a fork!
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set lowercase repository owner environment variable
|
||||||
|
run: |
|
||||||
|
echo "OWNER_LOWERCASE=${OWNER,,}" >> ${GITHUB_ENV}
|
||||||
|
env:
|
||||||
|
OWNER: "${{ github.repository_owner }}"
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
- name: Inject slug/short variables
|
||||||
|
uses: rlespinasse/github-slug-action@v5.0.0
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
install: true
|
||||||
|
driver-opts: |
|
||||||
|
image=moby/buildkit:master
|
||||||
|
network=host
|
||||||
|
- name: Install cosign
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: sigstore/cosign-installer@v3.8.1
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata tags and labels on PRs
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
id: meta-pr
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ env.OWNER_LOWERCASE }}/quartz
|
||||||
|
tags: |
|
||||||
|
type=raw,value=sha-${{ env.GITHUB_SHA_SHORT }}
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.source="https://github.com/${{ github.repository_owner }}/quartz"
|
||||||
|
- name: Extract metadata tags and labels for main, release or tag
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
flavor: |
|
||||||
|
latest=auto
|
||||||
|
images: ghcr.io/${{ env.OWNER_LOWERCASE }}/quartz
|
||||||
|
tags: |
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}.{{patch}}
|
||||||
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
|
||||||
|
type=raw,value=sha-${{ env.GITHUB_SHA_SHORT }}
|
||||||
|
labels: |
|
||||||
|
maintainer=${{ github.repository_owner }}
|
||||||
|
org.opencontainers.image.source="https://github.com/${{ github.repository_owner }}/quartz"
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: build-and-push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
build-args: |
|
||||||
|
GIT_SHA=${{ env.GITHUB_SHA }}
|
||||||
|
DOCKER_LABEL=sha-${{ env.GITHUB_SHA_SHORT }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags || steps.meta-pr.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels || steps.meta-pr.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha
|
||||||
1
.node-version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
v20.9.0
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
FROM node:20-slim as builder
|
FROM node:22-slim AS builder
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY package.json .
|
COPY package.json .
|
||||||
COPY package-lock.json* .
|
COPY package-lock.json* .
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
FROM node:20-slim
|
FROM node:22-slim
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY --from=builder /usr/src/app/ /usr/src/app/
|
COPY --from=builder /usr/src/app/ /usr/src/app/
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@@ -129,11 +129,11 @@ export default (() => {
|
|||||||
return <button id="btn">Click me</button>
|
return <button id="btn">Click me</button>
|
||||||
}
|
}
|
||||||
|
|
||||||
YourComponent.beforeDOM = `
|
YourComponent.beforeDOMLoaded = `
|
||||||
console.log("hello from before the page loads!")
|
console.log("hello from before the page loads!")
|
||||||
`
|
`
|
||||||
|
|
||||||
YourComponent.afterDOM = `
|
YourComponent.afterDOMLoaded = `
|
||||||
document.getElementById('btn').onclick = () => {
|
document.getElementById('btn').onclick = () => {
|
||||||
alert('button clicked!')
|
alert('button clicked!')
|
||||||
}
|
}
|
||||||
@@ -161,6 +161,18 @@ document.addEventListener("nav", () => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can also add the equivalent of a `beforeunload` event for [[SPA Routing]] via the `prenav` event.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
document.addEventListener("prenav", () => {
|
||||||
|
// executed after an SPA navigation is triggered but
|
||||||
|
// before the page is replaced
|
||||||
|
// one usage pattern is to store things in sessionStorage
|
||||||
|
// in the prenav and then conditionally load then in the consequent
|
||||||
|
// nav
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
It is best practice to track any event handlers via `window.addCleanup` to prevent memory leaks.
|
It is best practice to track any event handlers via `window.addCleanup` to prevent memory leaks.
|
||||||
This will get called on page navigation.
|
This will get called on page navigation.
|
||||||
|
|
||||||
@@ -180,7 +192,7 @@ export default (() => {
|
|||||||
return <button id="btn">Click me</button>
|
return <button id="btn">Click me</button>
|
||||||
}
|
}
|
||||||
|
|
||||||
YourComponent.afterDOM = script
|
YourComponent.afterDOMLoaded = script
|
||||||
return YourComponent
|
return YourComponent
|
||||||
}) satisfies QuartzComponentConstructor
|
}) satisfies QuartzComponentConstructor
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -25,10 +25,11 @@ The following sections will go into detail for what methods can be implemented f
|
|||||||
- `BuildCtx` is defined in `quartz/ctx.ts`. It consists of
|
- `BuildCtx` is defined in `quartz/ctx.ts`. It consists of
|
||||||
- `argv`: The command line arguments passed to the Quartz [[build]] command
|
- `argv`: The command line arguments passed to the Quartz [[build]] command
|
||||||
- `cfg`: The full Quartz [[configuration]]
|
- `cfg`: The full Quartz [[configuration]]
|
||||||
- `allSlugs`: a list of all the valid content slugs (see [[paths]] for more information on what a `ServerSlug` is)
|
- `allSlugs`: a list of all the valid content slugs (see [[paths]] for more information on what a slug is)
|
||||||
- `StaticResources` is defined in `quartz/resources.tsx`. It consists of
|
- `StaticResources` is defined in `quartz/resources.tsx`. It consists of
|
||||||
- `css`: a list of URLs for stylesheets that should be loaded
|
- `css`: a list of CSS style definitions that should be loaded. A CSS style is described with the `CSSResource` type which is also defined in `quartz/resources.tsx`. It accepts either a source URL or the inline content of the stylesheet.
|
||||||
- `js`: a list of scripts that should be loaded. A script is described with the `JSResource` type which is also defined in `quartz/resources.tsx`. It allows you to define a load time (either before or after the DOM has been loaded), whether it should be a module, and either the source URL or the inline content of the script.
|
- `js`: a list of scripts that should be loaded. A script is described with the `JSResource` type which is also defined in `quartz/resources.tsx`. It allows you to define a load time (either before or after the DOM has been loaded), whether it should be a module, and either the source URL or the inline content of the script.
|
||||||
|
- `additionalHead`: a list of JSX elements or functions that return JSX elements to be added to the `<head>` tag of the page. Functions receive the page's data as an argument and can conditionally render elements.
|
||||||
|
|
||||||
## Transformers
|
## Transformers
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ Transformers **map** over content, taking a Markdown file and outputting modifie
|
|||||||
```ts
|
```ts
|
||||||
export type QuartzTransformerPluginInstance = {
|
export type QuartzTransformerPluginInstance = {
|
||||||
name: string
|
name: string
|
||||||
textTransform?: (ctx: BuildCtx, src: string | Buffer) => string | Buffer
|
textTransform?: (ctx: BuildCtx, src: string) => string
|
||||||
markdownPlugins?: (ctx: BuildCtx) => PluggableList
|
markdownPlugins?: (ctx: BuildCtx) => PluggableList
|
||||||
htmlPlugins?: (ctx: BuildCtx) => PluggableList
|
htmlPlugins?: (ctx: BuildCtx) => PluggableList
|
||||||
externalResources?: (ctx: BuildCtx) => Partial<StaticResources>
|
externalResources?: (ctx: BuildCtx) => Partial<StaticResources>
|
||||||
@@ -85,8 +86,10 @@ export const Latex: QuartzTransformerPlugin<Options> = (opts?: Options) => {
|
|||||||
if (engine === "katex") {
|
if (engine === "katex") {
|
||||||
return {
|
return {
|
||||||
css: [
|
css: [
|
||||||
// base css
|
{
|
||||||
"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.css",
|
// base css
|
||||||
|
content: "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.css",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
js: [
|
js: [
|
||||||
{
|
{
|
||||||
@@ -97,8 +100,6 @@ export const Latex: QuartzTransformerPlugin<Options> = (opts?: Options) => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return {}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -234,7 +235,7 @@ export type WriteOptions = (data: {
|
|||||||
// the build context
|
// the build context
|
||||||
ctx: BuildCtx
|
ctx: BuildCtx
|
||||||
// the name of the file to emit (not including the file extension)
|
// the name of the file to emit (not including the file extension)
|
||||||
slug: ServerSlug
|
slug: FullSlug
|
||||||
// the file extension
|
// the file extension
|
||||||
ext: `.${string}` | ""
|
ext: `.${string}` | ""
|
||||||
// the file content to add
|
// the file content to add
|
||||||
@@ -260,11 +261,11 @@ export const ContentPage: QuartzEmitterPlugin = () => {
|
|||||||
...defaultContentPageLayout,
|
...defaultContentPageLayout,
|
||||||
pageBody: Content(),
|
pageBody: Content(),
|
||||||
}
|
}
|
||||||
const { head, header, beforeBody, pageBody, left, right, footer } = layout
|
const { head, header, beforeBody, pageBody, afterBody, left, right, footer } = layout
|
||||||
return {
|
return {
|
||||||
name: "ContentPage",
|
name: "ContentPage",
|
||||||
getQuartzComponents() {
|
getQuartzComponents() {
|
||||||
return [head, ...header, ...beforeBody, pageBody, ...left, ...right, footer]
|
return [head, ...header, ...beforeBody, pageBody, ...afterBody, ...left, ...right, footer]
|
||||||
},
|
},
|
||||||
async emit(ctx, content, resources, emit): Promise<FilePath[]> {
|
async emit(ctx, content, resources, emit): Promise<FilePath[]> {
|
||||||
const cfg = ctx.cfg.configuration
|
const cfg = ctx.cfg.configuration
|
||||||
@@ -272,7 +273,7 @@ export const ContentPage: QuartzEmitterPlugin = () => {
|
|||||||
const allFiles = content.map((c) => c[1].data)
|
const allFiles = content.map((c) => c[1].data)
|
||||||
for (const [tree, file] of content) {
|
for (const [tree, file] of content) {
|
||||||
const slug = canonicalizeServer(file.data.slug!)
|
const slug = canonicalizeServer(file.data.slug!)
|
||||||
const externalResources = pageResources(slug, resources)
|
const externalResources = pageResources(slug, file.data, resources)
|
||||||
const componentData: QuartzComponentProps = {
|
const componentData: QuartzComponentProps = {
|
||||||
fileData: file.data,
|
fileData: file.data,
|
||||||
externalResources,
|
externalResources,
|
||||||
|
|||||||
@@ -48,4 +48,4 @@ Here are the main types of slugs with a rough description of each type of path:
|
|||||||
- `SimpleSlug`: cannot be relative and shouldn't have `/index` as an ending or a file extension. It _can_ however have a trailing slash to indicate a folder path.
|
- `SimpleSlug`: cannot be relative and shouldn't have `/index` as an ending or a file extension. It _can_ however have a trailing slash to indicate a folder path.
|
||||||
- `RelativeURL`: must start with `.` or `..` to indicate it's a relative URL. Shouldn't have `/index` as an ending or a file extension but can contain a trailing slash.
|
- `RelativeURL`: must start with `.` or `..` to indicate it's a relative URL. Shouldn't have `/index` as an ending or a file extension but can contain a trailing slash.
|
||||||
|
|
||||||
To get a clearer picture of how these relate to each other, take a look at the path tests in `quartz/path.test.ts`.
|
To get a clearer picture of how these relate to each other, take a look at the path tests in `quartz/util/path.test.ts`.
|
||||||
|
|||||||
@@ -29,11 +29,14 @@ Some common frontmatter fields that are natively supported by Quartz:
|
|||||||
|
|
||||||
- `title`: Title of the page. If it isn't provided, Quartz will use the name of the file as the title.
|
- `title`: Title of the page. If it isn't provided, Quartz will use the name of the file as the title.
|
||||||
- `description`: Description of the page used for link previews.
|
- `description`: Description of the page used for link previews.
|
||||||
|
- `permalink`: A custom URL for the page that will remain constant even if the path to the file changes.
|
||||||
- `aliases`: Other names for this note. This is a list of strings.
|
- `aliases`: Other names for this note. This is a list of strings.
|
||||||
- `tags`: Tags for this note.
|
- `tags`: Tags for this note.
|
||||||
- `draft`: Whether to publish the page or not. This is one way to make [[private pages|pages private]] in Quartz.
|
- `draft`: Whether to publish the page or not. This is one way to make [[private pages|pages private]] in Quartz.
|
||||||
- `date`: A string representing the day the note was published. Normally uses `YYYY-MM-DD` format.
|
- `date`: A string representing the day the note was published. Normally uses `YYYY-MM-DD` format.
|
||||||
|
|
||||||
|
See [[Frontmatter]] for a complete list of frontmatter.
|
||||||
|
|
||||||
## Syncing your Content
|
## Syncing your Content
|
||||||
|
|
||||||
When your Quartz is at a point you're happy with, you can save your changes to GitHub.
|
When your Quartz is at a point you're happy with, you can save your changes to GitHub.
|
||||||
|
|||||||
@@ -21,3 +21,7 @@ This will start a local web server to run your Quartz on your computer. Open a w
|
|||||||
> - `--serve`: run a local hot-reloading server to preview your Quartz
|
> - `--serve`: run a local hot-reloading server to preview your Quartz
|
||||||
> - `--port`: what port to run the local preview server on
|
> - `--port`: what port to run the local preview server on
|
||||||
> - `--concurrency`: how many threads to use to parse notes
|
> - `--concurrency`: how many threads to use to parse notes
|
||||||
|
|
||||||
|
> [!warning] Not to be used for production
|
||||||
|
> Serve mode is intended for local previews only.
|
||||||
|
> For production workloads, see the page on [[hosting]].
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const config: QuartzConfig = {
|
|||||||
This part of the configuration concerns anything that can affect the whole site. The following is a list breaking down all the things you can configure:
|
This part of the configuration concerns anything that can affect the whole site. The following is a list breaking down all the things you can configure:
|
||||||
|
|
||||||
- `pageTitle`: title of the site. This is also used when generating the [[RSS Feed]] for your site.
|
- `pageTitle`: title of the site. This is also used when generating the [[RSS Feed]] for your site.
|
||||||
|
- `pageTitleSuffix`: a string added to the end of the page title. This only applies to the browser tab title, not the title shown at the top of the page.
|
||||||
- `enableSPA`: whether to enable [[SPA Routing]] on your site.
|
- `enableSPA`: whether to enable [[SPA Routing]] on your site.
|
||||||
- `enablePopovers`: whether to enable [[popover previews]] on your site.
|
- `enablePopovers`: whether to enable [[popover previews]] on your site.
|
||||||
- `analytics`: what to use for analytics on your site. Values can be
|
- `analytics`: what to use for analytics on your site. Values can be
|
||||||
@@ -28,6 +29,11 @@ This part of the configuration concerns anything that can affect the whole site.
|
|||||||
- `{ provider: 'google', tagId: '<your-google-tag>' }`: use Google Analytics;
|
- `{ provider: 'google', tagId: '<your-google-tag>' }`: use Google Analytics;
|
||||||
- `{ provider: 'plausible' }` (managed) or `{ provider: 'plausible', host: '<your-plausible-host>' }` (self-hosted): use [Plausible](https://plausible.io/);
|
- `{ provider: 'plausible' }` (managed) or `{ provider: 'plausible', host: '<your-plausible-host>' }` (self-hosted): use [Plausible](https://plausible.io/);
|
||||||
- `{ provider: 'umami', host: '<your-umami-host>', websiteId: '<your-umami-website-id>' }`: use [Umami](https://umami.is/);
|
- `{ provider: 'umami', host: '<your-umami-host>', websiteId: '<your-umami-website-id>' }`: use [Umami](https://umami.is/);
|
||||||
|
- `{ provider: 'goatcounter', websiteId: 'my-goatcounter-id' }` (managed) or `{ provider: 'goatcounter', websiteId: 'my-goatcounter-id', host: 'my-goatcounter-domain.com', scriptSrc: 'https://my-url.to/counter.js' }` (self-hosted) use [GoatCounter](https://goatcounter.com);
|
||||||
|
- `{ provider: 'posthog', apiKey: '<your-posthog-project-apiKey>', host: '<your-posthog-host>' }`: use [Posthog](https://posthog.com/);
|
||||||
|
- `{ provider: 'tinylytics', siteId: '<your-site-id>' }`: use [Tinylytics](https://tinylytics.app/);
|
||||||
|
- `{ provider: 'cabin' }` or `{ provider: 'cabin', host: 'https://cabin.example.com' }` (custom domain): use [Cabin](https://withcabin.com);
|
||||||
|
- `{provider: 'clarity', projectId: '<your-clarity-id-code' }`: use [Microsoft clarity](https://clarity.microsoft.com/). The project id can be found on top of the overview page.
|
||||||
- `locale`: used for [[i18n]] and date formatting
|
- `locale`: used for [[i18n]] and date formatting
|
||||||
- `baseUrl`: this is used for sitemaps and RSS feeds that require an absolute URL to know where the canonical 'home' of your site lives. This is normally the deployed URL of your site (e.g. `quartz.jzhao.xyz` for this site). Do not include the protocol (i.e. `https://`) or any leading or trailing slashes.
|
- `baseUrl`: this is used for sitemaps and RSS feeds that require an absolute URL to know where the canonical 'home' of your site lives. This is normally the deployed URL of your site (e.g. `quartz.jzhao.xyz` for this site). Do not include the protocol (i.e. `https://`) or any leading or trailing slashes.
|
||||||
- This should also include the subpath if you are [[hosting]] on GitHub pages without a custom domain. For example, if my repository is `jackyzha0/quartz`, GitHub pages would deploy to `https://jackyzha0.github.io/quartz` and the `baseUrl` would be `jackyzha0.github.io/quartz`.
|
- This should also include the subpath if you are [[hosting]] on GitHub pages without a custom domain. For example, if my repository is `jackyzha0/quartz`, GitHub pages would deploy to `https://jackyzha0.github.io/quartz` and the `baseUrl` would be `jackyzha0.github.io/quartz`.
|
||||||
@@ -49,6 +55,7 @@ This part of the configuration concerns anything that can affect the whole site.
|
|||||||
- `secondary`: link colour, current [[graph view|graph]] node
|
- `secondary`: link colour, current [[graph view|graph]] node
|
||||||
- `tertiary`: hover states and visited [[graph view|graph]] nodes
|
- `tertiary`: hover states and visited [[graph view|graph]] nodes
|
||||||
- `highlight`: internal link background, highlighted text, [[syntax highlighting|highlighted lines of code]]
|
- `highlight`: internal link background, highlighted text, [[syntax highlighting|highlighted lines of code]]
|
||||||
|
- `textHighlight`: markdown highlighted text background
|
||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
|
|
||||||
@@ -73,10 +80,10 @@ You can customize the behaviour of Quartz by adding, removing and reordering plu
|
|||||||
> [!note]
|
> [!note]
|
||||||
> Each node is modified by every transformer _in order_. Some transformers are position sensitive, so you may need to pay particular attention to whether they need to come before or after certain other plugins.
|
> Each node is modified by every transformer _in order_. Some transformers are position sensitive, so you may need to pay particular attention to whether they need to come before or after certain other plugins.
|
||||||
|
|
||||||
You should take care to add the plugin to the right entry corresponding to its plugin type. For example, to add the [[ExplicitPublish]] plugin (a [[tags/plugin/transformer|Transformer]], you would add the following line:
|
You should take care to add the plugin to the right entry corresponding to its plugin type. For example, to add the [[ExplicitPublish]] plugin (a [[tags/plugin/filter|Filter]]), you would add the following line:
|
||||||
|
|
||||||
```ts title="quartz.config.ts"
|
```ts title="quartz.config.ts"
|
||||||
transformers: [
|
filters: [
|
||||||
...
|
...
|
||||||
Plugin.ExplicitPublish(),
|
Plugin.ExplicitPublish(),
|
||||||
...
|
...
|
||||||
@@ -96,8 +103,30 @@ transformers: [
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
Some plugins are included by default in the[ `quartz.config.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz.config.ts), but there are more available.
|
Some plugins are included by default in the [`quartz.config.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz.config.ts), but there are more available.
|
||||||
|
|
||||||
You can see a list of all plugins and their configuration options [[tags/plugin|here]].
|
You can see a list of all plugins and their configuration options [[tags/plugin|here]].
|
||||||
|
|
||||||
If you'd like to make your own plugins, see the [[making plugins|making custom plugins]] guide.
|
If you'd like to make your own plugins, see the [[making plugins|making custom plugins]] guide.
|
||||||
|
|
||||||
|
## Fonts
|
||||||
|
|
||||||
|
Fonts can be specified as a `string` or a `FontSpecification`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// string
|
||||||
|
typography: {
|
||||||
|
header: "Schibsted Grotesk",
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
// FontSpecification
|
||||||
|
typography: {
|
||||||
|
header: {
|
||||||
|
name: "Schibsted Grotesk",
|
||||||
|
weights: [400, 700],
|
||||||
|
includeItalic: true,
|
||||||
|
},
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
31
docs/features/Citations.md
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
title: Citations
|
||||||
|
tags:
|
||||||
|
- feature/transformer
|
||||||
|
---
|
||||||
|
|
||||||
|
Quartz uses [rehype-citation](https://github.com/timlrx/rehype-citation) to support parsing of a BibTex bibliography file.
|
||||||
|
|
||||||
|
Under the default configuration, a citation key `[@templeton2024scaling]` will be exported as `(Templeton et al., 2024)`.
|
||||||
|
|
||||||
|
> [!example]- BibTex file
|
||||||
|
>
|
||||||
|
> ```bib title="bibliography.bib"
|
||||||
|
> @article{templeton2024scaling,
|
||||||
|
> title={Scaling Monosemanticity: Extracting Interpretable Features from Claude 3 Sonnet},
|
||||||
|
> author={Templeton, Adly and Conerly, Tom and Marcus, Jonathan and Lindsey, Jack and Bricken, Trenton and Chen, Brian and Pearce, Adam and Citro, Craig and Ameisen, Emmanuel and Jones, Andy and Cunningham, Hoagy and Turner, Nicholas L and McDougall, Callum and MacDiarmid, Monte and Freeman, C. Daniel and Sumers, Theodore R. and Rees, Edward and Batson, Joshua and Jermyn, Adam and Carter, Shan and Olah, Chris and Henighan, Tom},
|
||||||
|
> year={2024},
|
||||||
|
> journal={Transformer Circuits Thread},
|
||||||
|
> url={https://transformer-circuits.pub/2024/scaling-monosemanticity/index.html}
|
||||||
|
> }
|
||||||
|
> ```
|
||||||
|
|
||||||
|
> [!note] Behaviour of references
|
||||||
|
>
|
||||||
|
> By default, the references will be included at the end of the file. To control where the references to be included, uses `[^ref]`
|
||||||
|
>
|
||||||
|
> Refer to `rehype-citation` docs for more information.
|
||||||
|
|
||||||
|
## Customization
|
||||||
|
|
||||||
|
Citation parsing is a functionality of the [[plugins/Citations|Citation]] plugin. **This plugin is not enabled by default**. See the plugin page for customization options.
|
||||||
@@ -3,5 +3,5 @@ Quartz comes shipped with a Docker image that will allow you to preview your Qua
|
|||||||
You can run the below one-liner to run Quartz in Docker.
|
You can run the below one-liner to run Quartz in Docker.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run --rm -itp 8080:8080 $(docker build -q .)
|
docker run --rm -itp 8080:8080 -p 3001:3001 -v ./content:/usr/src/app/content $(docker build -q .)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -39,6 +39,17 @@ a & b & c
|
|||||||
\end{bmatrix}
|
\end{bmatrix}
|
||||||
$$
|
$$
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{array}{rll}
|
||||||
|
E \psi &= H\psi & \text{Expanding the Hamiltonian Operator} \\
|
||||||
|
&= -\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2} \psi + \frac{1}{2}m\omega x^2 \psi & \text{Using the ansatz $\psi(x) = e^{-kx^2}f(x)$, hoping to cancel the $x^2$ term} \\
|
||||||
|
&= -\frac{\hbar^2}{2m} [4k^2x^2f(x)+2(-2kx)f'(x) + f''(x)]e^{-kx^2} + \frac{1}{2}m\omega x^2 f(x)e^{-kx^2} &\text{Removing the $e^{-kx^2}$ term from both sides} \\
|
||||||
|
& \Downarrow \\
|
||||||
|
Ef(x) &= -\frac{\hbar^2}{2m} [4k^2x^2f(x)-4kxf'(x) + f''(x)] + \frac{1}{2}m\omega x^2 f(x) & \text{Choosing $k=\frac{im}{2}\sqrt{\frac{\omega}{\hbar}}$ to cancel the $x^2$ term, via $-\frac{\hbar^2}{2m}4k^2=\frac{1}{2}m \omega$} \\
|
||||||
|
&= -\frac{\hbar^2}{2m} [-4kxf'(x) + f''(x)] \\
|
||||||
|
\end{array}
|
||||||
|
$$
|
||||||
|
|
||||||
> [!warn]
|
> [!warn]
|
||||||
> Due to limitations in the [underlying parsing library](https://github.com/remarkjs/remark-math), block math in Quartz requires the `$$` delimiters to be on newlines like above.
|
> Due to limitations in the [underlying parsing library](https://github.com/remarkjs/remark-math), block math in Quartz requires the `$$` delimiters to be on newlines like above.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
Quartz emits an RSS feed for all the content on your site by generating an `index.xml` file that RSS readers can subscribe to. Because of the RSS spec, this requires the `baseUrl` property in your [[configuration]] to be set properly for RSS readers to pick it up properly.
|
Quartz emits an RSS feed for all the content on your site by generating an `index.xml` file that RSS readers can subscribe to. Because of the RSS spec, this requires the `baseUrl` property in your [[configuration]] to be set properly for RSS readers to pick it up properly.
|
||||||
|
|
||||||
|
> [!info]
|
||||||
|
> After deploying, the generated RSS link will be available at `https://${baseUrl}/index.xml` by default.
|
||||||
|
>
|
||||||
|
> The `index.xml` path can be customized by passing the `rssSlug` option to the [[ContentIndex]] plugin.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
This functionality is provided by the [[ContentIndex]] plugin. See the plugin page for customization options.
|
This functionality is provided by the [[ContentIndex]] plugin. See the plugin page for customization options.
|
||||||
|
|||||||
28
docs/features/Roam Research compatibility.md
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
title: "Roam Research Compatibility"
|
||||||
|
tags:
|
||||||
|
- feature/transformer
|
||||||
|
---
|
||||||
|
|
||||||
|
[Roam Research](https://roamresearch.com) is a note-taking tool that organizes your knowledge graph in a unique and interconnected way.
|
||||||
|
|
||||||
|
Quartz supports transforming the special Markdown syntax from Roam Research (like `{{[[components]]}}` and other formatting) into
|
||||||
|
regular Markdown via the [[RoamFlavoredMarkdown]] plugin.
|
||||||
|
|
||||||
|
```typescript title="quartz.config.ts"
|
||||||
|
plugins: {
|
||||||
|
transformers: [
|
||||||
|
// ...
|
||||||
|
Plugin.RoamFlavoredMarkdown(),
|
||||||
|
Plugin.ObsidianFlavoredMarkdown(),
|
||||||
|
// ...
|
||||||
|
],
|
||||||
|
},
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!warning]
|
||||||
|
> As seen above placement of `Plugin.RoamFlavoredMarkdown()` within `quartz.config.ts` is very important. It must come before `Plugin.ObsidianFlavoredMarkdown()`.
|
||||||
|
|
||||||
|
## Customization
|
||||||
|
|
||||||
|
This functionality is provided by the [[RoamFlavoredMarkdown]] plugin. See the plugin page for customization options.
|
||||||
@@ -9,6 +9,7 @@ A backlink for a note is a link from another note to that note. Links in the bac
|
|||||||
## Customization
|
## Customization
|
||||||
|
|
||||||
- Removing backlinks: delete all usages of `Component.Backlinks()` from `quartz.layout.ts`.
|
- Removing backlinks: delete all usages of `Component.Backlinks()` from `quartz.layout.ts`.
|
||||||
|
- Hide when empty: hide `Backlinks` if given page doesn't contain any backlinks (default to `true`). To disable this, use `Component.Backlinks({ hideWhenEmpty: false })`.
|
||||||
- Component: `quartz/components/Backlinks.tsx`
|
- Component: `quartz/components/Backlinks.tsx`
|
||||||
- Style: `quartz/components/styles/backlinks.scss`
|
- Style: `quartz/components/styles/backlinks.scss`
|
||||||
- Script: `quartz/components/scripts/search.inline.ts`
|
- Script: `quartz/components/scripts/search.inline.ts`
|
||||||
|
|||||||
127
docs/features/comments.md
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
---
|
||||||
|
title: Comments
|
||||||
|
tags:
|
||||||
|
- component
|
||||||
|
---
|
||||||
|
|
||||||
|
Quartz also has the ability to hook into various providers to enable readers to leave comments on your site.
|
||||||
|
|
||||||
|
![[giscus-example.png]]
|
||||||
|
|
||||||
|
As of today, only [Giscus](https://giscus.app/) is supported out of the box but PRs to support other providers are welcome!
|
||||||
|
|
||||||
|
## Providers
|
||||||
|
|
||||||
|
### Giscus
|
||||||
|
|
||||||
|
First, make sure that the [[setting up your GitHub repository|GitHub]] repository you are using for your Quartz meets the following requirements:
|
||||||
|
|
||||||
|
1. The **repository is [public](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/setting-repository-visibility#making-a-repository-public)**, otherwise visitors will not be able to view the discussion.
|
||||||
|
2. The **[giscus](https://github.com/apps/giscus) app is installed**, otherwise visitors will not be able to comment and react.
|
||||||
|
3. The **Discussions feature is turned on** by [enabling it for your repository](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/enabling-or-disabling-github-discussions-for-a-repository).
|
||||||
|
|
||||||
|
Then, use the [Giscus site](https://giscus.app/#repository) to figure out what your `repoId` and `categoryId` should be. Make sure you select `Announcements` for the Discussion category.
|
||||||
|
|
||||||
|
![[giscus-repo.png]]
|
||||||
|
|
||||||
|
![[giscus-discussion.png]]
|
||||||
|
|
||||||
|
After entering both your repository and selecting the discussion category, Giscus will compute some IDs that you'll need to provide back to Quartz. You won't need to manually add the script yourself as Quartz will handle that part for you but will need these values in the next step!
|
||||||
|
|
||||||
|
![[giscus-results.png]]
|
||||||
|
|
||||||
|
Finally, in `quartz.layout.ts`, edit the `afterBody` field of `sharedPageComponents` to include the following options but with the values you got from above:
|
||||||
|
|
||||||
|
```ts title="quartz.layout.ts"
|
||||||
|
afterBody: [
|
||||||
|
Component.Comments({
|
||||||
|
provider: 'giscus',
|
||||||
|
options: {
|
||||||
|
// from data-repo
|
||||||
|
repo: 'jackyzha0/quartz',
|
||||||
|
// from data-repo-id
|
||||||
|
repoId: 'MDEwOlJlcG9zaXRvcnkzODcyMTMyMDg',
|
||||||
|
// from data-category
|
||||||
|
category: 'Announcements',
|
||||||
|
// from data-category-id
|
||||||
|
categoryId: 'DIC_kwDOFxRnmM4B-Xg6',
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
```
|
||||||
|
|
||||||
|
### Customization
|
||||||
|
|
||||||
|
Quartz also exposes a few of the other Giscus options as well and you can provide them the same way `repo`, `repoId`, `category`, and `categoryId` are provided.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
type Options = {
|
||||||
|
provider: "giscus"
|
||||||
|
options: {
|
||||||
|
repo: `${string}/${string}`
|
||||||
|
repoId: string
|
||||||
|
category: string
|
||||||
|
categoryId: string
|
||||||
|
|
||||||
|
// Url to folder with custom themes
|
||||||
|
// defaults to 'https://${cfg.baseUrl}/static/giscus'
|
||||||
|
themeUrl?: string
|
||||||
|
|
||||||
|
// filename for light theme .css file
|
||||||
|
// defaults to 'light'
|
||||||
|
lightTheme?: string
|
||||||
|
|
||||||
|
// filename for dark theme .css file
|
||||||
|
// defaults to 'dark'
|
||||||
|
darkTheme?: string
|
||||||
|
|
||||||
|
// how to map pages -> discussions
|
||||||
|
// defaults to 'url'
|
||||||
|
mapping?: "url" | "title" | "og:title" | "specific" | "number" | "pathname"
|
||||||
|
|
||||||
|
// use strict title matching
|
||||||
|
// defaults to true
|
||||||
|
strict?: boolean
|
||||||
|
|
||||||
|
// whether to enable reactions for the main post
|
||||||
|
// defaults to true
|
||||||
|
reactionsEnabled?: boolean
|
||||||
|
|
||||||
|
// where to put the comment input box relative to the comments
|
||||||
|
// defaults to 'bottom'
|
||||||
|
inputPosition?: "top" | "bottom"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Custom CSS theme
|
||||||
|
|
||||||
|
Quartz supports custom theme for Giscus. To use a custom CSS theme, place the `.css` file inside the `quartz/static` folder and set the configuration values.
|
||||||
|
|
||||||
|
For example, if you have a light theme `light-theme.css`, a dark theme `dark-theme.css`, and your Quartz site is hosted at `https://example.com/`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
afterBody: [
|
||||||
|
Component.Comments({
|
||||||
|
provider: 'giscus',
|
||||||
|
options: {
|
||||||
|
// Other options
|
||||||
|
|
||||||
|
themeUrl: "https://example.com/static/giscus", // corresponds to quartz/static/giscus/
|
||||||
|
lightTheme: "light-theme", // corresponds to light-theme.css in quartz/static/giscus/
|
||||||
|
darkTheme: "dark-theme", // corresponds to dark-theme.css quartz/static/giscus/
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Conditionally display comments
|
||||||
|
|
||||||
|
Quartz can conditionally display the comment box based on a field `comments` in the frontmatter. By default, all pages will display comments, to disable it for a specific page, set `comments` to `false`.
|
||||||
|
|
||||||
|
```
|
||||||
|
---
|
||||||
|
title: Comments disabled here!
|
||||||
|
comments: false
|
||||||
|
---
|
||||||
|
```
|
||||||
@@ -27,12 +27,10 @@ Component.Explorer({
|
|||||||
folderClickBehavior: "collapse", // what happens when you click a folder ("link" to navigate to folder page on click or "collapse" to collapse folder on click)
|
folderClickBehavior: "collapse", // what happens when you click a folder ("link" to navigate to folder page on click or "collapse" to collapse folder on click)
|
||||||
folderDefaultState: "collapsed", // default state of folders ("collapsed" or "open")
|
folderDefaultState: "collapsed", // default state of folders ("collapsed" or "open")
|
||||||
useSavedState: true, // whether to use local storage to save "state" (which folders are opened) of explorer
|
useSavedState: true, // whether to use local storage to save "state" (which folders are opened) of explorer
|
||||||
// Sort order: folders first, then files. Sort folders and files alphabetically
|
// omitted but shown later
|
||||||
sortFn: (a, b) => {
|
sortFn: ...,
|
||||||
... // default implementation shown later
|
filterFn: ...,
|
||||||
},
|
mapFn: ...,
|
||||||
filterFn: filterFn: (node) => node.name !== "tags", // filters out 'tags' folder
|
|
||||||
mapFn: undefined,
|
|
||||||
// what order to apply functions in
|
// what order to apply functions in
|
||||||
order: ["filter", "map", "sort"],
|
order: ["filter", "map", "sort"],
|
||||||
})
|
})
|
||||||
@@ -54,17 +52,23 @@ Want to customize it even more?
|
|||||||
## Advanced customization
|
## Advanced customization
|
||||||
|
|
||||||
This component allows you to fully customize all of its behavior. You can pass a custom `sort`, `filter` and `map` function.
|
This component allows you to fully customize all of its behavior. You can pass a custom `sort`, `filter` and `map` function.
|
||||||
All functions you can pass work with the `FileNode` class, which has the following properties:
|
All functions you can pass work with the `FileTrieNode` class, which has the following properties:
|
||||||
|
|
||||||
```ts title="quartz/components/ExplorerNode.tsx" {2-5}
|
```ts title="quartz/components/Explorer.tsx"
|
||||||
export class FileNode {
|
class FileTrieNode {
|
||||||
children: FileNode[] // children of current node
|
isFolder: boolean
|
||||||
name: string // last part of slug
|
children: Array<FileTrieNode>
|
||||||
displayName: string // what actually should be displayed in the explorer
|
data: ContentDetails | null
|
||||||
file: QuartzPluginData | null // set if node is a file, see `QuartzPluginData` for more detail
|
}
|
||||||
depth: number // depth of current node
|
```
|
||||||
|
|
||||||
... // rest of implementation
|
```ts title="quartz/plugins/emitters/contentIndex.tsx"
|
||||||
|
export type ContentDetails = {
|
||||||
|
slug: FullSlug
|
||||||
|
title: string
|
||||||
|
links: SimpleSlug[]
|
||||||
|
tags: string[]
|
||||||
|
content: string
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -74,15 +78,14 @@ Every function you can pass is optional. By default, only a `sort` function will
|
|||||||
// Sort order: folders first, then files. Sort folders and files alphabetically
|
// Sort order: folders first, then files. Sort folders and files alphabetically
|
||||||
Component.Explorer({
|
Component.Explorer({
|
||||||
sortFn: (a, b) => {
|
sortFn: (a, b) => {
|
||||||
if ((!a.file && !b.file) || (a.file && b.file)) {
|
if ((!a.isFolder && !b.isFolder) || (a.isFolder && b.isFolder)) {
|
||||||
// sensitivity: "base": Only strings that differ in base letters compare as unequal. Examples: a ≠ b, a = á, a = A
|
|
||||||
// numeric: true: Whether numeric collation should be used, such that "1" < "2" < "10"
|
|
||||||
return a.displayName.localeCompare(b.displayName, undefined, {
|
return a.displayName.localeCompare(b.displayName, undefined, {
|
||||||
numeric: true,
|
numeric: true,
|
||||||
sensitivity: "base",
|
sensitivity: "base",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (a.file && !b.file) {
|
|
||||||
|
if (!a.isFolder && b.isFolder) {
|
||||||
return 1
|
return 1
|
||||||
} else {
|
} else {
|
||||||
return -1
|
return -1
|
||||||
@@ -100,41 +103,23 @@ For more information on how to use `sort`, `filter` and `map`, you can check [Ar
|
|||||||
Type definitions look like this:
|
Type definitions look like this:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
sortFn: (a: FileNode, b: FileNode) => number
|
type SortFn = (a: FileTrieNode, b: FileTrieNode) => number
|
||||||
filterFn: (node: FileNode) => boolean
|
type FilterFn = (node: FileTrieNode) => boolean
|
||||||
mapFn: (node: FileNode) => void
|
type MapFn = (node: FileTrieNode) => void
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!tip]
|
|
||||||
> You can check if a `FileNode` is a folder or a file like this:
|
|
||||||
>
|
|
||||||
> ```ts
|
|
||||||
> if (node.file) {
|
|
||||||
> // node is a file
|
|
||||||
> } else {
|
|
||||||
> // node is a folder
|
|
||||||
> }
|
|
||||||
> ```
|
|
||||||
|
|
||||||
## Basic examples
|
## Basic examples
|
||||||
|
|
||||||
These examples show the basic usage of `sort`, `map` and `filter`.
|
These examples show the basic usage of `sort`, `map` and `filter`.
|
||||||
|
|
||||||
### Use `sort` to put files first
|
### Use `sort` to put files first
|
||||||
|
|
||||||
Using this example, the explorer will alphabetically sort everything, but put all **files** above all **folders**.
|
Using this example, the explorer will alphabetically sort everything.
|
||||||
|
|
||||||
```ts title="quartz.layout.ts"
|
```ts title="quartz.layout.ts"
|
||||||
Component.Explorer({
|
Component.Explorer({
|
||||||
sortFn: (a, b) => {
|
sortFn: (a, b) => {
|
||||||
if ((!a.file && !b.file) || (a.file && b.file)) {
|
return a.displayName.localeCompare(b.displayName)
|
||||||
return a.displayName.localeCompare(b.displayName)
|
|
||||||
}
|
|
||||||
if (a.file && !b.file) {
|
|
||||||
return -1
|
|
||||||
} else {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
@@ -146,30 +131,43 @@ Using this example, the display names of all `FileNodes` (folders + files) will
|
|||||||
```ts title="quartz.layout.ts"
|
```ts title="quartz.layout.ts"
|
||||||
Component.Explorer({
|
Component.Explorer({
|
||||||
mapFn: (node) => {
|
mapFn: (node) => {
|
||||||
node.displayName = node.displayName.toUpperCase()
|
return (node.displayName = node.displayName.toUpperCase())
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Remove list of elements (`filter`)
|
### Remove list of elements (`filter`)
|
||||||
|
|
||||||
Using this example, you can remove elements from your explorer by providing an array of folders/files using the `omit` set.
|
Using this example, you can remove elements from your explorer by providing an array of folders/files to exclude.
|
||||||
|
Note that this example filters on the title but you can also do it via slug or any other field available on `FileTrieNode`.
|
||||||
|
|
||||||
```ts title="quartz.layout.ts"
|
```ts title="quartz.layout.ts"
|
||||||
Component.Explorer({
|
Component.Explorer({
|
||||||
filterFn: (node) => {
|
filterFn: (node) => {
|
||||||
// set containing names of everything you want to filter out
|
// set containing names of everything you want to filter out
|
||||||
const omit = new Set(["authoring content", "tags", "hosting"])
|
const omit = new Set(["authoring content", "tags", "hosting"])
|
||||||
return !omit.has(node.name.toLowerCase())
|
return !omit.has(node.data.title.toLowerCase())
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
You can customize this by changing the entries of the `omit` set. Simply add all folder or file names you want to remove.
|
### Remove files by tag
|
||||||
|
|
||||||
|
You can access the tags of a file by `node.data.tags`.
|
||||||
|
|
||||||
|
```ts title="quartz.layout.ts"
|
||||||
|
Component.Explorer({
|
||||||
|
filterFn: (node) => {
|
||||||
|
// exclude files with the tag "explorerexclude"
|
||||||
|
return node.data.tags.includes("explorerexclude") !== true
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
### Show every element in explorer
|
### Show every element in explorer
|
||||||
|
|
||||||
To override the default filter function that removes the `tags` folder from the explorer, you can set the filter function to `undefined`.
|
By default, the explorer will filter out the `tags` folder.
|
||||||
|
To override the default filter function, you can set the filter function to `undefined`.
|
||||||
|
|
||||||
```ts title="quartz.layout.ts"
|
```ts title="quartz.layout.ts"
|
||||||
Component.Explorer({
|
Component.Explorer({
|
||||||
@@ -181,10 +179,12 @@ Component.Explorer({
|
|||||||
|
|
||||||
> [!tip]
|
> [!tip]
|
||||||
> When writing more complicated functions, the `layout` file can start to look very cramped.
|
> When writing more complicated functions, the `layout` file can start to look very cramped.
|
||||||
> You can fix this by defining your functions in another file.
|
> You can fix this by defining your sort functions outside of the component
|
||||||
|
> and passing it in.
|
||||||
>
|
>
|
||||||
> ```ts title="functions.ts"
|
> ```ts title="quartz.layout.ts"
|
||||||
> import { Options } from "./quartz/components/ExplorerNode"
|
> import { Options } from "./quartz/components/ExplorerNode"
|
||||||
|
>
|
||||||
> export const mapFn: Options["mapFn"] = (node) => {
|
> export const mapFn: Options["mapFn"] = (node) => {
|
||||||
> // implement your function here
|
> // implement your function here
|
||||||
> }
|
> }
|
||||||
@@ -194,16 +194,12 @@ Component.Explorer({
|
|||||||
> export const sortFn: Options["sortFn"] = (a, b) => {
|
> export const sortFn: Options["sortFn"] = (a, b) => {
|
||||||
> // implement your function here
|
> // implement your function here
|
||||||
> }
|
> }
|
||||||
> ```
|
|
||||||
>
|
>
|
||||||
> You can then import them like this:
|
|
||||||
>
|
|
||||||
> ```ts title="quartz.layout.ts"
|
|
||||||
> import { mapFn, filterFn, sortFn } from "./functions.ts"
|
|
||||||
> Component.Explorer({
|
> Component.Explorer({
|
||||||
> mapFn: mapFn,
|
> // ... your other options
|
||||||
> filterFn: filterFn,
|
> mapFn,
|
||||||
> sortFn: sortFn,
|
> filterFn,
|
||||||
|
> sortFn,
|
||||||
> })
|
> })
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
@@ -214,93 +210,11 @@ To add emoji prefixes (📁 for folders, 📄 for files), you could use a map fu
|
|||||||
```ts title="quartz.layout.ts"
|
```ts title="quartz.layout.ts"
|
||||||
Component.Explorer({
|
Component.Explorer({
|
||||||
mapFn: (node) => {
|
mapFn: (node) => {
|
||||||
// dont change name of root node
|
if (node.isFolder) {
|
||||||
if (node.depth > 0) {
|
node.displayName = "📁 " + node.displayName
|
||||||
// set emoji for file/folder
|
} else {
|
||||||
if (node.file) {
|
node.displayName = "📄 " + node.displayName
|
||||||
node.displayName = "📄 " + node.displayName
|
|
||||||
} else {
|
|
||||||
node.displayName = "📁 " + node.displayName
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Putting it all together
|
|
||||||
|
|
||||||
In this example, we're going to customize the explorer by using functions from examples above to [[#Add emoji prefix | add emoji prefixes]], [[#remove-list-of-elements-filter| filter out some folders]] and [[#use-sort-to-put-files-first | sort with files above folders]].
|
|
||||||
|
|
||||||
```ts title="quartz.layout.ts"
|
|
||||||
Component.Explorer({
|
|
||||||
filterFn: sampleFilterFn,
|
|
||||||
mapFn: sampleMapFn,
|
|
||||||
sortFn: sampleSortFn,
|
|
||||||
order: ["filter", "sort", "map"],
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
Notice how we customized the `order` array here. This is done because the default order applies the `sort` function last. While this normally works well, it would cause unintended behavior here, since we changed the first characters of all display names. In our example, `sort` would be applied based off the emoji prefix instead of the first _real_ character.
|
|
||||||
|
|
||||||
To fix this, we just changed around the order and apply the `sort` function before changing the display names in the `map` function.
|
|
||||||
|
|
||||||
### Use `sort` with pre-defined sort order
|
|
||||||
|
|
||||||
Here's another example where a map containing file/folder names (as slugs) is used to define the sort order of the explorer in quartz. All files/folders that aren't listed inside of `nameOrderMap` will appear at the top of that folders hierarchy level.
|
|
||||||
|
|
||||||
It's also worth mentioning, that the smaller the number set in `nameOrderMap`, the higher up the entry will be in the explorer. Incrementing every folder/file by 100, makes ordering files in their folders a lot easier. Lastly, this example still allows you to use a `mapFn` or frontmatter titles to change display names, as it uses slugs for `nameOrderMap` (which is unaffected by display name changes).
|
|
||||||
|
|
||||||
```ts title="quartz.layout.ts"
|
|
||||||
Component.Explorer({
|
|
||||||
sortFn: (a, b) => {
|
|
||||||
const nameOrderMap: Record<string, number> = {
|
|
||||||
"poetry-folder": 100,
|
|
||||||
"essay-folder": 200,
|
|
||||||
"research-paper-file": 201,
|
|
||||||
"dinosaur-fossils-file": 300,
|
|
||||||
"other-folder": 400,
|
|
||||||
}
|
|
||||||
|
|
||||||
let orderA = 0
|
|
||||||
let orderB = 0
|
|
||||||
|
|
||||||
if (a.file && a.file.slug) {
|
|
||||||
orderA = nameOrderMap[a.file.slug] || 0
|
|
||||||
} else if (a.name) {
|
|
||||||
orderA = nameOrderMap[a.name] || 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if (b.file && b.file.slug) {
|
|
||||||
orderB = nameOrderMap[b.file.slug] || 0
|
|
||||||
} else if (b.name) {
|
|
||||||
orderB = nameOrderMap[b.name] || 0
|
|
||||||
}
|
|
||||||
|
|
||||||
return orderA - orderB
|
|
||||||
},
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
For reference, this is how the quartz explorer window would look like with that example:
|
|
||||||
|
|
||||||
```
|
|
||||||
📖 Poetry Folder
|
|
||||||
📑 Essay Folder
|
|
||||||
⚗️ Research Paper File
|
|
||||||
🦴 Dinosaur Fossils File
|
|
||||||
🔮 Other Folder
|
|
||||||
```
|
|
||||||
|
|
||||||
And this is how the file structure would look like:
|
|
||||||
|
|
||||||
```
|
|
||||||
index.md
|
|
||||||
poetry-folder
|
|
||||||
index.md
|
|
||||||
essay-folder
|
|
||||||
index.md
|
|
||||||
research-paper-file.md
|
|
||||||
dinosaur-fossils-file.md
|
|
||||||
other-folder
|
|
||||||
index.md
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -30,4 +30,4 @@ As with folder listings, you can also provide a description and title for a tag
|
|||||||
|
|
||||||
## Customization
|
## Customization
|
||||||
|
|
||||||
The folder listings are a functionality of the [[FolderPage]] plugin, the tag listings of the [[TagPage]] plugin. See the plugin pages for customization options.
|
Quartz allows you to define a custom sort ordering for content on both page types. The folder listings are a functionality of the [[FolderPage]] plugin, the tag listings of the [[TagPage]] plugin. See the plugin pages for customization options.
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ Component.Graph({
|
|||||||
opacityScale: 1, // how quickly do we fade out the labels when zooming out?
|
opacityScale: 1, // how quickly do we fade out the labels when zooming out?
|
||||||
removeTags: [], // what tags to remove from the graph
|
removeTags: [], // what tags to remove from the graph
|
||||||
showTags: true, // whether to show tags in the graph
|
showTags: true, // whether to show tags in the graph
|
||||||
|
enableRadial: false, // whether to constrain the graph, similar to Obsidian
|
||||||
},
|
},
|
||||||
globalGraph: {
|
globalGraph: {
|
||||||
drag: true,
|
drag: true,
|
||||||
@@ -49,6 +50,7 @@ Component.Graph({
|
|||||||
opacityScale: 1,
|
opacityScale: 1,
|
||||||
removeTags: [], // what tags to remove from the graph
|
removeTags: [], // what tags to remove from the graph
|
||||||
showTags: true, // whether to show tags in the graph
|
showTags: true, // whether to show tags in the graph
|
||||||
|
enableRadial: true, // whether to constrain the graph, similar to Obsidian
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ Quartz can generate a list of recent notes based on some filtering and sorting c
|
|||||||
|
|
||||||
- Changing the title from "Recent notes": pass in an additional parameter to `Component.RecentNotes({ title: "Recent writing" })`
|
- Changing the title from "Recent notes": pass in an additional parameter to `Component.RecentNotes({ title: "Recent writing" })`
|
||||||
- Changing the number of recent notes: pass in an additional parameter to `Component.RecentNotes({ limit: 5 })`
|
- Changing the number of recent notes: pass in an additional parameter to `Component.RecentNotes({ limit: 5 })`
|
||||||
|
- Display the note's tags (defaults to true): `Component.RecentNotes({ showTags: false })`
|
||||||
- Show a 'see more' link: pass in an additional parameter to `Component.RecentNotes({ linkToMore: "tags/components" })`. This field should be a full slug to a page that exists.
|
- Show a 'see more' link: pass in an additional parameter to `Component.RecentNotes({ linkToMore: "tags/components" })`. This field should be a full slug to a page that exists.
|
||||||
- Customize filtering: pass in an additional parameter to `Component.RecentNotes({ filter: someFilterFunction })`. The filter function should be a function that has the signature `(f: QuartzPluginData) => boolean`.
|
- Customize filtering: pass in an additional parameter to `Component.RecentNotes({ filter: someFilterFunction })`. The filter function should be a function that has the signature `(f: QuartzPluginData) => boolean`.
|
||||||
- Customize sorting: pass in an additional parameter to `Component.RecentNotes({ sort: someSortFunction })`. By default, Quartz will sort by date and then tie break lexographically. The sort function should be a function that has the signature `(f1: QuartzPluginData, f2: QuartzPluginData) => number`. See `byDateAndAlphabetical` in `quartz/components/PageList.tsx` for an example.
|
- Customize sorting: pass in an additional parameter to `Component.RecentNotes({ sort: someSortFunction })`. By default, Quartz will sort by date and then tie break lexographically. The sort function should be a function that has the signature `(f1: QuartzPluginData, f2: QuartzPluginData) => number`. See `byDateAndAlphabetical` in `quartz/components/PageList.tsx` for an example.
|
||||||
|
|||||||
19
docs/features/social images.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
title: "Social Media Preview Cards"
|
||||||
|
---
|
||||||
|
|
||||||
|
A lot of social media platforms can display a rich preview for your website when sharing a link (most notably, a cover image, a title and a description).
|
||||||
|
|
||||||
|
Quartz can also dynamically generate and use new cover images for every page to be used in link previews on social media for you.
|
||||||
|
|
||||||
|
## Showcase
|
||||||
|
|
||||||
|
After enabling the [[CustomOgImages]] emitter plugin, the social media link preview for [[authoring content | Authoring Content]] looks like this:
|
||||||
|
|
||||||
|
| Light | Dark |
|
||||||
|
| ----------------------------------- | ---------------------------------- |
|
||||||
|
| ![[social-image-preview-light.png]] | ![[social-image-preview-dark.png]] |
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
This functionality is provided by the [[CustomOgImages]] plugin. See the plugin page for customization options.
|
||||||
@@ -95,6 +95,16 @@ const [age, setAge] = useState(50)
|
|||||||
const [name, setName] = useState("Taylor")
|
const [name, setName] = useState("Taylor")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Inline Highlighting
|
||||||
|
|
||||||
|
Append {:lang} to the end of inline code to highlight it like a regular code block.
|
||||||
|
|
||||||
|
```
|
||||||
|
This is an array `[1, 2, 3]{:js}` of numbers 1 through 3.
|
||||||
|
```
|
||||||
|
|
||||||
|
This is an array `[1, 2, 3]{:js}` of numbers 1 through 3.
|
||||||
|
|
||||||
### Line numbers
|
### Line numbers
|
||||||
|
|
||||||
Syntax highlighting has line numbers configured automatically. If you want to start line numbers at a specific number, use `showLineNumbers{number}`:
|
Syntax highlighting has line numbers configured automatically. If you want to start line numbers at a specific number, use `showLineNumbers{number}`:
|
||||||
|
|||||||
@@ -2,22 +2,11 @@
|
|||||||
draft: true
|
draft: true
|
||||||
---
|
---
|
||||||
|
|
||||||
## high priority backlog
|
|
||||||
|
|
||||||
- static dead link detection
|
|
||||||
- block links: https://help.obsidian.md/Linking+notes+and+files/Internal+links#Link+to+a+block+in+a+note
|
|
||||||
- note/header/block transcludes: https://help.obsidian.md/Linking+notes+and+files/Embedding+files
|
|
||||||
- docker support
|
|
||||||
|
|
||||||
## misc backlog
|
## misc backlog
|
||||||
|
|
||||||
- breadcrumbs component
|
- static dead link detection
|
||||||
- cursor chat extension
|
- cursor chat extension
|
||||||
- https://giscus.app/ extension
|
|
||||||
- sidenotes? https://github.com/capnfabs/paperesque
|
- sidenotes? https://github.com/capnfabs/paperesque
|
||||||
- direct match in search using double quotes
|
- direct match in search using double quotes
|
||||||
- https://help.obsidian.md/Advanced+topics/Using+Obsidian+URI
|
- https://help.obsidian.md/Advanced+topics/Using+Obsidian+URI
|
||||||
- audio/video embed styling
|
|
||||||
- Canvas
|
- Canvas
|
||||||
- parse all images in page: use this for page lists if applicable?
|
|
||||||
- CV mode? with print stylesheet
|
|
||||||
|
|||||||
@@ -57,18 +57,18 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Fetch all history for git info
|
fetch-depth: 0 # Fetch all history for git info
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18.14
|
node-version: 22
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
- name: Build Quartz
|
- name: Build Quartz
|
||||||
run: npx quartz build
|
run: npx quartz build
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-pages-artifact@v2
|
uses: actions/upload-pages-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: public
|
path: public
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
id: deployment
|
id: deployment
|
||||||
uses: actions/deploy-pages@v2
|
uses: actions/deploy-pages@v4
|
||||||
```
|
```
|
||||||
|
|
||||||
Then:
|
Then:
|
||||||
@@ -182,37 +182,33 @@ Using `docs.example.com` is an example of a subdomain. They're a simple way of c
|
|||||||
|
|
||||||
## GitLab Pages
|
## GitLab Pages
|
||||||
|
|
||||||
In your local Quartz, create a new file `.gitlab-ci.yaml`.
|
In your local Quartz, create a new file `.gitlab-ci.yml`.
|
||||||
|
|
||||||
```yaml title=".gitlab-ci.yaml"
|
```yaml title=".gitlab-ci.yml"
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
variables:
|
image: node:20
|
||||||
NODE_VERSION: "18.14"
|
cache: # Cache modules in between jobs
|
||||||
|
key: $CI_COMMIT_REF_SLUG
|
||||||
|
paths:
|
||||||
|
- .npm/
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_REF_NAME == "v4"'
|
- if: '$CI_COMMIT_REF_NAME == "v4"'
|
||||||
before_script:
|
before_script:
|
||||||
- apt-get update -q && apt-get install -y nodejs npm
|
|
||||||
- npm install -g n
|
|
||||||
- n $NODE_VERSION
|
|
||||||
- hash -r
|
- hash -r
|
||||||
- npm ci
|
- npm ci --cache .npm --prefer-offline
|
||||||
script:
|
script:
|
||||||
- npx quartz build
|
- npx quartz build
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- ~/.npm/
|
|
||||||
key: "${CI_COMMIT_REF_SLUG}-node-${CI_COMMIT_REF_NAME}"
|
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- gitlab-org-docker
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
@@ -250,3 +246,43 @@ server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Using Apache
|
||||||
|
|
||||||
|
Here's an example of how to do this with Apache:
|
||||||
|
|
||||||
|
```apache title=".htaccess"
|
||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
ErrorDocument 404 /404.html
|
||||||
|
|
||||||
|
# Rewrite rule for .html extension removal (with directory check)
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI}.html -f
|
||||||
|
RewriteRule ^(.*)$ $1.html [L]
|
||||||
|
|
||||||
|
# Handle directory requests explicitly
|
||||||
|
RewriteCond %{REQUEST_FILENAME} -d
|
||||||
|
RewriteRule ^(.*)/$ $1/index.html [L]
|
||||||
|
```
|
||||||
|
|
||||||
|
Don't forget to activate brotli / gzip compression.
|
||||||
|
|
||||||
|
### Using Caddy
|
||||||
|
|
||||||
|
Here's and example of how to do this with Caddy:
|
||||||
|
|
||||||
|
```caddy title="Caddyfile"
|
||||||
|
example.com {
|
||||||
|
root * /path/to/quartz/public
|
||||||
|
try_files {path} {path}.html {path}/ =404
|
||||||
|
file_server
|
||||||
|
encode gzip
|
||||||
|
|
||||||
|
handle_errors {
|
||||||
|
rewrite * /{err.status_code}.html
|
||||||
|
file_server
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
BIN
docs/images/custom-social-image-preview-dark.png
Normal file
|
After Width: | Height: | Size: 129 KiB |
BIN
docs/images/custom-social-image-preview-light.png
Normal file
|
After Width: | Height: | Size: 132 KiB |
BIN
docs/images/giscus-discussion.png
Normal file
|
After Width: | Height: | Size: 88 KiB |
BIN
docs/images/giscus-example.png
Normal file
|
After Width: | Height: | Size: 572 KiB |
BIN
docs/images/giscus-repo.png
Normal file
|
After Width: | Height: | Size: 108 KiB |
BIN
docs/images/giscus-results.png
Normal file
|
After Width: | Height: | Size: 171 KiB |
|
Before Width: | Height: | Size: 55 KiB |
BIN
docs/images/quartz-layout-desktop.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
docs/images/quartz-layout-mobile.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
docs/images/quartz-layout-tablet.png
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
docs/images/social-image-preview-dark.png
Normal file
|
After Width: | Height: | Size: 139 KiB |
BIN
docs/images/social-image-preview-light.png
Normal file
|
After Width: | Height: | Size: 134 KiB |
@@ -6,7 +6,7 @@ Quartz is a fast, batteries-included static-site generator that transforms Markd
|
|||||||
|
|
||||||
## 🪴 Get Started
|
## 🪴 Get Started
|
||||||
|
|
||||||
Quartz requires **at least [Node](https://nodejs.org/) v18.14** and `npm` v9.3.1 to function correctly. Ensure you have this installed on your machine before continuing.
|
Quartz requires **at least [Node](https://nodejs.org/) v20** and `npm` v9.3.1 to function correctly. Ensure you have this installed on your machine before continuing.
|
||||||
|
|
||||||
Then, in your terminal of choice, enter the following commands line by line:
|
Then, in your terminal of choice, enter the following commands line by line:
|
||||||
|
|
||||||
@@ -31,13 +31,13 @@ If you prefer instructions in a video format you can try following Nicole van de
|
|||||||
|
|
||||||
## 🔧 Features
|
## 🔧 Features
|
||||||
|
|
||||||
- [[Obsidian compatibility]], [[full-text search]], [[graph view]], note transclusion, [[wikilinks]], [[backlinks]], [[features/Latex|Latex]], [[syntax highlighting]], [[popover previews]], [[Docker Support]], [[i18n|internationalization]] and [many more](./features) right out of the box
|
- [[Obsidian compatibility]], [[full-text search]], [[graph view]], note transclusion, [[wikilinks]], [[backlinks]], [[features/Latex|Latex]], [[syntax highlighting]], [[popover previews]], [[Docker Support]], [[i18n|internationalization]], [[comments]] and [many more](./features/) right out of the box
|
||||||
- Hot-reload for both configuration and content
|
- Hot-reload for both configuration and content
|
||||||
- Simple JSX layouts and [[creating components|page components]]
|
- Simple JSX layouts and [[creating components|page components]]
|
||||||
- [[SPA Routing|Ridiculously fast page loads]] and tiny bundle sizes
|
- [[SPA Routing|Ridiculously fast page loads]] and tiny bundle sizes
|
||||||
- Fully-customizable parsing, filtering, and page generation through [[making plugins|plugins]]
|
- Fully-customizable parsing, filtering, and page generation through [[making plugins|plugins]]
|
||||||
|
|
||||||
For a comprehensive list of features, visit the [features page](/features). You can read more about the _why_ behind these features on the [[philosophy]] page and a technical overview on the [[architecture]] page.
|
For a comprehensive list of features, visit the [features page](./features/). You can read more about the _why_ behind these features on the [[philosophy]] page and a technical overview on the [[architecture]] page.
|
||||||
|
|
||||||
### 🚧 Troubleshooting + Updating
|
### 🚧 Troubleshooting + Updating
|
||||||
|
|
||||||
|
|||||||
62
docs/layout-components.md
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
---
|
||||||
|
title: Higher-Order Layout Components
|
||||||
|
---
|
||||||
|
|
||||||
|
Quartz provides several higher-order components that help with layout composition and responsive design. These components wrap other components to add additional functionality or modify their behavior.
|
||||||
|
|
||||||
|
## `Flex` Component
|
||||||
|
|
||||||
|
The `Flex` component creates a [flexible box layout](https://developer.mozilla.org/en-US/docs/Web/CSS/flex) that can arrange child components in various ways. It's particularly useful for creating responsive layouts and organizing components in rows or columns.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
type FlexConfig = {
|
||||||
|
components: {
|
||||||
|
Component: QuartzComponent
|
||||||
|
grow?: boolean // whether component should grow to fill space
|
||||||
|
shrink?: boolean // whether component should shrink if needed
|
||||||
|
basis?: string // initial main size of the component
|
||||||
|
order?: number // order in flex container
|
||||||
|
align?: "start" | "end" | "center" | "stretch" // cross-axis alignment
|
||||||
|
justify?: "start" | "end" | "center" | "between" | "around" // main-axis alignment
|
||||||
|
}[]
|
||||||
|
direction?: "row" | "row-reverse" | "column" | "column-reverse"
|
||||||
|
wrap?: "nowrap" | "wrap" | "wrap-reverse"
|
||||||
|
gap?: string
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example Usage
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
Component.Flex({
|
||||||
|
components: [
|
||||||
|
{
|
||||||
|
Component: Component.Search(),
|
||||||
|
grow: true, // Search will grow to fill available space
|
||||||
|
},
|
||||||
|
{ Component: Component.Darkmode() }, // Darkmode keeps its natural size
|
||||||
|
],
|
||||||
|
direction: "row",
|
||||||
|
gap: "1rem",
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
## `MobileOnly` Component
|
||||||
|
|
||||||
|
The `MobileOnly` component is a wrapper that makes its child component only visible on mobile devices. This is useful for creating responsive layouts where certain components should only appear on smaller screens.
|
||||||
|
|
||||||
|
### Example Usage
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
Component.MobileOnly(Component.Spacer())
|
||||||
|
```
|
||||||
|
|
||||||
|
## `DesktopOnly` Component
|
||||||
|
|
||||||
|
The `DesktopOnly` component is the counterpart to `MobileOnly`. It makes its child component only visible on desktop devices. This helps create responsive layouts where certain components should only appear on larger screens.
|
||||||
|
|
||||||
|
### Example Usage
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
Component.DesktopOnly(Component.TableOfContents())
|
||||||
|
```
|
||||||
@@ -12,15 +12,20 @@ export interface FullPageLayout {
|
|||||||
header: QuartzComponent[] // laid out horizontally
|
header: QuartzComponent[] // laid out horizontally
|
||||||
beforeBody: QuartzComponent[] // laid out vertically
|
beforeBody: QuartzComponent[] // laid out vertically
|
||||||
pageBody: QuartzComponent // single component
|
pageBody: QuartzComponent // single component
|
||||||
left: QuartzComponent[] // vertical on desktop, horizontal on mobile
|
afterBody: QuartzComponent[] // laid out vertically
|
||||||
right: QuartzComponent[] // vertical on desktop, horizontal on mobile
|
left: QuartzComponent[] // vertical on desktop and tablet, horizontal on mobile
|
||||||
|
right: QuartzComponent[] // vertical on desktop, horizontal on tablet and mobile
|
||||||
footer: QuartzComponent // single component
|
footer: QuartzComponent // single component
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
These correspond to following parts of the page:
|
These correspond to following parts of the page:
|
||||||
|
|
||||||
![[quartz layout.png|800]]
|
| Layout | Preview |
|
||||||
|
| ------------------------------- | ----------------------------------- |
|
||||||
|
| Desktop (width > 1200px) | ![[quartz-layout-desktop.png\|800]] |
|
||||||
|
| Tablet (800px < width < 1200px) | ![[quartz-layout-tablet.png\|800]] |
|
||||||
|
| Mobile (width < 800px) | ![[quartz-layout-mobile.png\|800]] |
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> There are two additional layout fields that are _not_ shown in the above diagram.
|
> There are two additional layout fields that are _not_ shown in the above diagram.
|
||||||
@@ -30,7 +35,26 @@ These correspond to following parts of the page:
|
|||||||
|
|
||||||
Quartz **components**, like plugins, can take in additional properties as configuration options. If you're familiar with React terminology, you can think of them as Higher-order Components.
|
Quartz **components**, like plugins, can take in additional properties as configuration options. If you're familiar with React terminology, you can think of them as Higher-order Components.
|
||||||
|
|
||||||
See [a list of all the components](component.md) for all available components along with their configuration options. You can also checkout the guide on [[creating components]] if you're interested in further customizing the behaviour of Quartz.
|
See [a list of all the components](component.md) for all available components along with their configuration options. Additionally, Quartz provides several built-in higher-order components for layout composition - see [[layout-components]] for more details.
|
||||||
|
|
||||||
|
You can also checkout the guide on [[creating components]] if you're interested in further customizing the behaviour of Quartz.
|
||||||
|
|
||||||
|
### Layout breakpoints
|
||||||
|
|
||||||
|
Quartz has different layouts depending on the width the screen viewing the website.
|
||||||
|
|
||||||
|
The breakpoints for layouts can be configured in `variables.scss`.
|
||||||
|
|
||||||
|
- `mobile`: screen width below this size will use mobile layout.
|
||||||
|
- `desktop`: screen width above this size will use desktop layout.
|
||||||
|
- Screen width between `mobile` and `desktop` width will use the tablet layout.
|
||||||
|
|
||||||
|
```scss
|
||||||
|
$breakpoints: (
|
||||||
|
mobile: 800px,
|
||||||
|
desktop: 1200px,
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
### Style
|
### Style
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ The emitter supports the following aliases:
|
|||||||
- `alias`
|
- `alias`
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin has no configuration options.
|
This plugin has no configuration options.
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ This plugin emits all non-Markdown static assets in your content folder (like im
|
|||||||
Note that all static assets will then be accessible through its path on your generated site, i.e: `host.me/path/to/static.pdf`
|
Note that all static assets will then be accessible through its path on your generated site, i.e: `host.me/path/to/static.pdf`
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin has no configuration options.
|
This plugin has no configuration options.
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ This plugin emits a `CNAME` record that points your subdomain to the default dom
|
|||||||
|
|
||||||
If you want to use a custom domain name like `quartz.example.com` for the site, then this is needed.
|
If you want to use a custom domain name like `quartz.example.com` for the site, then this is needed.
|
||||||
|
|
||||||
See [[Hosting]] for more information.
|
See [[hosting|Hosting]] for more information.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin has no configuration options.
|
This plugin has no configuration options.
|
||||||
|
|
||||||
|
|||||||
24
docs/plugins/Citations.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
title: "Citations"
|
||||||
|
tags:
|
||||||
|
- plugin/transformer
|
||||||
|
---
|
||||||
|
|
||||||
|
This plugin adds Citation support to Quartz.
|
||||||
|
|
||||||
|
> [!note]
|
||||||
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
|
- `bibliographyFile`: the path to the bibliography file. Defaults to `./bibliography.bib`. This is relative to git source of your vault.
|
||||||
|
- `suppressBibliography`: whether to suppress the bibliography at the end of the document. Defaults to `false`.
|
||||||
|
- `linkCitations`: whether to link citations to the bibliography. Defaults to `false`.
|
||||||
|
- `csl`: the citation style to use. Defaults to `apa`. Reference [rehype-citation](https://rehype-citation.netlify.app/custom-csl) for more options.
|
||||||
|
- `prettyLink`: whether to use pretty links for citations. Defaults to `true`.
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
- Category: Transformer
|
||||||
|
- Function name: `Plugin.Citations()`.
|
||||||
|
- Source: [`quartz/plugins/transformers/citations.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/citations.ts).
|
||||||
@@ -7,7 +7,7 @@ tags:
|
|||||||
This plugin manages and emits the static resources required for the Quartz framework. This includes CSS stylesheets and JavaScript scripts that enhance the functionality and aesthetics of the generated site. See also the `cdnCaching` option in the `theme` section of the [[configuration]].
|
This plugin manages and emits the static resources required for the Quartz framework. This includes CSS stylesheets and JavaScript scripts that enhance the functionality and aesthetics of the generated site. See also the `cdnCaching` option in the `theme` section of the [[configuration]].
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin has no configuration options.
|
This plugin has no configuration options.
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ This plugin emits both RSS and an XML sitemap for your site. The [[RSS Feed]] al
|
|||||||
This plugin emits a comprehensive index of the site's content, generating additional resources such as a sitemap, an RSS feed, and a
|
This plugin emits a comprehensive index of the site's content, generating additional resources such as a sitemap, an RSS feed, and a
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
@@ -17,6 +17,7 @@ This plugin accepts the following configuration options:
|
|||||||
- `enableRSS`: If `true` (default), produces an RSS feed (`index.xml`) with recent content updates.
|
- `enableRSS`: If `true` (default), produces an RSS feed (`index.xml`) with recent content updates.
|
||||||
- `rssLimit`: Defines the maximum number of entries to include in the RSS feed, helping to focus on the most recent or relevant content. Defaults to `10`.
|
- `rssLimit`: Defines the maximum number of entries to include in the RSS feed, helping to focus on the most recent or relevant content. Defaults to `10`.
|
||||||
- `rssFullHtml`: If `true`, the RSS feed includes full HTML content. Otherwise it includes just summaries.
|
- `rssFullHtml`: If `true`, the RSS feed includes full HTML content. Otherwise it includes just summaries.
|
||||||
|
- `rssSlug`: Slug to the generated RSS feed XML file. Defaults to `"index"`.
|
||||||
- `includeEmptyFiles`: If `true` (default), content files with no body text are included in the generated index and resources.
|
- `includeEmptyFiles`: If `true` (default), content files with no body text are included in the generated index and resources.
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ tags:
|
|||||||
This plugin is a core component of the Quartz framework. It generates the HTML pages for each piece of Markdown content. It emits the full-page [[layout]], including headers, footers, and body content, among others.
|
This plugin is a core component of the Quartz framework. It generates the HTML pages for each piece of Markdown content. It emits the full-page [[layout]], including headers, footers, and body content, among others.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin has no configuration options.
|
This plugin has no configuration options.
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ tags:
|
|||||||
This plugin parses links and processes them to point to the right places. It is also needed for embedded links (like images). See [[Obsidian compatibility]] for more information.
|
This plugin parses links and processes them to point to the right places. It is also needed for embedded links (like images). See [[Obsidian compatibility]] for more information.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ tags:
|
|||||||
This plugin determines the created, modified, and published dates for a document using three potential data sources: frontmatter metadata, Git history, and the filesystem. See [[authoring content#Syntax]] for more information.
|
This plugin determines the created, modified, and published dates for a document using three potential data sources: frontmatter metadata, Git history, and the filesystem. See [[authoring content#Syntax]] for more information.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
- `priority`: The data sources to consult for date information. Highest priority first. Possible values are `"frontmatter"`, `"git"`, and `"filesystem"`. Defaults to `"frontmatter", "git", "filesystem"]`.
|
- `priority`: The data sources to consult for date information. Highest priority first. Possible values are `"frontmatter"`, `"git"`, and `"filesystem"`. Defaults to `["frontmatter", "git", "filesystem"]`.
|
||||||
|
|
||||||
|
When loading the frontmatter, the value of [[Frontmatter#List]] is used.
|
||||||
|
|
||||||
> [!warning]
|
> [!warning]
|
||||||
> If you rely on `git` for dates, make sure `defaultDateType` is set to `modified` in `quartz.config.ts`.
|
> If you rely on `git` for dates, make sure `defaultDateType` is set to `modified` in `quartz.config.ts`.
|
||||||
|
|||||||
360
docs/plugins/CustomOgImages.md
Normal file
@@ -0,0 +1,360 @@
|
|||||||
|
---
|
||||||
|
title: Custom OG Images
|
||||||
|
tags:
|
||||||
|
- feature/emitter
|
||||||
|
---
|
||||||
|
|
||||||
|
The Custom OG Images emitter plugin generates social media preview images for your pages. It uses [satori](https://github.com/vercel/satori) to convert HTML/CSS into images, allowing you to create beautiful and consistent social media preview cards for your content.
|
||||||
|
|
||||||
|
> [!note]
|
||||||
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Automatically generates social media preview images for each page
|
||||||
|
- Supports both light and dark mode themes
|
||||||
|
- Customizable through frontmatter properties
|
||||||
|
- Fallback to default image when needed
|
||||||
|
- Full control over image design through custom components
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
> [!info] Info
|
||||||
|
>
|
||||||
|
> The `baseUrl` property in your [[configuration]] must be set properly for social images to work correctly, as they require absolute paths.
|
||||||
|
|
||||||
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
|
```typescript title="quartz.config.ts"
|
||||||
|
import { CustomOgImages } from "./quartz/plugins/emitters/ogImage"
|
||||||
|
|
||||||
|
const config: QuartzConfig = {
|
||||||
|
plugins: {
|
||||||
|
emitters: [
|
||||||
|
CustomOgImages({
|
||||||
|
colorScheme: "lightMode", // what colors to use for generating image, same as theme colors from config, valid values are "darkMode" and "lightMode"
|
||||||
|
width: 1200, // width to generate with (in pixels)
|
||||||
|
height: 630, // height to generate with (in pixels)
|
||||||
|
excludeRoot: false, // wether to exclude "/" index path to be excluded from auto generated images (false = use auto, true = use default og image)
|
||||||
|
imageStructure: defaultImage, // custom image component to use
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuration Options
|
||||||
|
|
||||||
|
| Option | Type | Default | Description |
|
||||||
|
| ---------------- | --------- | ------------ | ----------------------------------------------------------------- |
|
||||||
|
| `colorScheme` | string | "lightMode" | Theme to use for generating images ("darkMode" or "lightMode") |
|
||||||
|
| `width` | number | 1200 | Width of the generated image in pixels |
|
||||||
|
| `height` | number | 630 | Height of the generated image in pixels |
|
||||||
|
| `excludeRoot` | boolean | false | Whether to exclude the root index page from auto-generated images |
|
||||||
|
| `imageStructure` | component | defaultImage | Custom component to use for image generation |
|
||||||
|
|
||||||
|
## Frontmatter Properties
|
||||||
|
|
||||||
|
The following properties can be used to customize your link previews:
|
||||||
|
|
||||||
|
| Property | Alias | Summary |
|
||||||
|
| ------------------- | ---------------- | ----------------------------------- |
|
||||||
|
| `socialDescription` | `description` | Description to be used for preview. |
|
||||||
|
| `socialImage` | `image`, `cover` | Link to preview image. |
|
||||||
|
|
||||||
|
The `socialImage` property should contain a link to an image relative to `quartz/static`. If you have a folder for all your images in `quartz/static/my-images`, an example for `socialImage` could be `"my-images/cover.png"`.
|
||||||
|
|
||||||
|
> [!info] Info
|
||||||
|
>
|
||||||
|
> The priority for what image will be used for the cover image looks like the following: `frontmatter property > generated image (if enabled) > default image`.
|
||||||
|
>
|
||||||
|
> The default image (`quartz/static/og-image.png`) will only be used as a fallback if nothing else is set. If the Custom OG Images emitter plugin is enabled, it will be treated as the new default per page, but can be overwritten by setting the `socialImage` frontmatter property for that page.
|
||||||
|
|
||||||
|
## Customization
|
||||||
|
|
||||||
|
You can fully customize how the images being generated look by passing your own component to `imageStructure`. This component takes JSX + some page metadata/config options and converts it to an image using [satori](https://github.com/vercel/satori). Vercel provides an [online playground](https://og-playground.vercel.app/) that can be used to preview how your JSX looks like as a picture. This is ideal for prototyping your custom design.
|
||||||
|
|
||||||
|
### Fonts
|
||||||
|
|
||||||
|
You will also be passed an array containing a header and a body font (where the first entry is header and the second is body). The fonts matches the ones selected in `theme.typography.header` and `theme.typography.body` from `quartz.config.ts` and will be passed in the format required by [`satori`](https://github.com/vercel/satori). To use them in CSS, use the `.name` property (e.g. `fontFamily: fonts[1].name` to use the "body" font family).
|
||||||
|
|
||||||
|
An example of a component using the header font could look like this:
|
||||||
|
|
||||||
|
```tsx title="socialImage.tsx"
|
||||||
|
export const myImage: SocialImageOptions["imageStructure"] = (...) => {
|
||||||
|
return <p style={{ fontFamily: fonts[0].name }}>Cool Header!</p>
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!example]- Local fonts
|
||||||
|
>
|
||||||
|
> For cases where you use a local fonts under `static` folder, make sure to set the correct `@font-face` in `custom.scss`
|
||||||
|
>
|
||||||
|
> ```scss title="custom.scss"
|
||||||
|
> @font-face {
|
||||||
|
> font-family: "Newsreader";
|
||||||
|
> font-style: normal;
|
||||||
|
> font-weight: normal;
|
||||||
|
> font-display: swap;
|
||||||
|
> src: url("/static/Newsreader.woff2") format("woff2");
|
||||||
|
> }
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> Then in `quartz/util/og.tsx`, you can load the Satori fonts like so:
|
||||||
|
>
|
||||||
|
> ```tsx title="quartz/util/og.tsx"
|
||||||
|
> import { joinSegments, QUARTZ } from "../path"
|
||||||
|
> import fs from "fs"
|
||||||
|
> import path from "path"
|
||||||
|
>
|
||||||
|
> const newsreaderFontPath = joinSegments(QUARTZ, "static", "Newsreader.woff2")
|
||||||
|
> export async function getSatoriFonts(headerFont: FontSpecification, bodyFont: FontSpecification) {
|
||||||
|
> // ... rest of implementation remains same
|
||||||
|
> const fonts: SatoriOptions["fonts"] = [
|
||||||
|
> ...headerFontData.map((data, idx) => ({
|
||||||
|
> name: headerFontName,
|
||||||
|
> data,
|
||||||
|
> weight: headerWeights[idx],
|
||||||
|
> style: "normal" as const,
|
||||||
|
> })),
|
||||||
|
> ...bodyFontData.map((data, idx) => ({
|
||||||
|
> name: bodyFontName,
|
||||||
|
> data,
|
||||||
|
> weight: bodyWeights[idx],
|
||||||
|
> style: "normal" as const,
|
||||||
|
> })),
|
||||||
|
> {
|
||||||
|
> name: "Newsreader",
|
||||||
|
> data: await fs.promises.readFile(path.resolve(newsreaderFontPath)),
|
||||||
|
> weight: 400,
|
||||||
|
> style: "normal" as const,
|
||||||
|
> },
|
||||||
|
> ]
|
||||||
|
>
|
||||||
|
> return fonts
|
||||||
|
> }
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> This font then can be used with your custom structure.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
Here are some example image components you can use as a starting point:
|
||||||
|
|
||||||
|
### Basic Example
|
||||||
|
|
||||||
|
This example will generate images that look as follows:
|
||||||
|
|
||||||
|
| Light | Dark |
|
||||||
|
| ------------------------------------------ | ----------------------------------------- |
|
||||||
|
| ![[custom-social-image-preview-light.png]] | ![[custom-social-image-preview-dark.png]] |
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { SatoriOptions } from "satori/wasm"
|
||||||
|
import { GlobalConfiguration } from "../cfg"
|
||||||
|
import { SocialImageOptions, UserOpts } from "./imageHelper"
|
||||||
|
import { QuartzPluginData } from "../plugins/vfile"
|
||||||
|
|
||||||
|
export const customImage: SocialImageOptions["imageStructure"] = (
|
||||||
|
cfg: GlobalConfiguration,
|
||||||
|
userOpts: UserOpts,
|
||||||
|
title: string,
|
||||||
|
description: string,
|
||||||
|
fonts: SatoriOptions["fonts"],
|
||||||
|
fileData: QuartzPluginData,
|
||||||
|
) => {
|
||||||
|
// How many characters are allowed before switching to smaller font
|
||||||
|
const fontBreakPoint = 22
|
||||||
|
const useSmallerFont = title.length > fontBreakPoint
|
||||||
|
|
||||||
|
const { colorScheme } = userOpts
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
justifyContent: "flex-start",
|
||||||
|
alignItems: "center",
|
||||||
|
height: "100%",
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
height: "100%",
|
||||||
|
width: "100%",
|
||||||
|
backgroundColor: cfg.theme.colors[colorScheme].light,
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: "2.5rem",
|
||||||
|
paddingTop: "2rem",
|
||||||
|
paddingBottom: "2rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
color: cfg.theme.colors[colorScheme].dark,
|
||||||
|
fontSize: useSmallerFont ? 70 : 82,
|
||||||
|
marginLeft: "4rem",
|
||||||
|
textAlign: "center",
|
||||||
|
marginRight: "4rem",
|
||||||
|
fontFamily: fonts[0].name,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
color: cfg.theme.colors[colorScheme].dark,
|
||||||
|
fontSize: 44,
|
||||||
|
marginLeft: "8rem",
|
||||||
|
marginRight: "8rem",
|
||||||
|
lineClamp: 3,
|
||||||
|
fontFamily: fonts[1].name,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{description}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: "100%",
|
||||||
|
width: "2vw",
|
||||||
|
position: "absolute",
|
||||||
|
backgroundColor: cfg.theme.colors[colorScheme].tertiary,
|
||||||
|
opacity: 0.85,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Advanced Example
|
||||||
|
|
||||||
|
The following example includes a customized social image with a custom background and formatted date:
|
||||||
|
|
||||||
|
```typescript title="custom-og.tsx"
|
||||||
|
export const og: SocialImageOptions["Component"] = (
|
||||||
|
cfg: GlobalConfiguration,
|
||||||
|
fileData: QuartzPluginData,
|
||||||
|
{ colorScheme }: Options,
|
||||||
|
title: string,
|
||||||
|
description: string,
|
||||||
|
fonts: SatoriOptions["fonts"],
|
||||||
|
) => {
|
||||||
|
let created: string | undefined
|
||||||
|
let reading: string | undefined
|
||||||
|
if (fileData.dates) {
|
||||||
|
created = formatDate(getDate(cfg, fileData)!, cfg.locale)
|
||||||
|
}
|
||||||
|
const { minutes, text: _timeTaken, words: _words } = readingTime(fileData.text!)
|
||||||
|
reading = i18n(cfg.locale).components.contentMeta.readingTime({
|
||||||
|
minutes: Math.ceil(minutes),
|
||||||
|
})
|
||||||
|
|
||||||
|
const Li = [created, reading]
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "relative",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "flex-start",
|
||||||
|
height: "100%",
|
||||||
|
width: "100%",
|
||||||
|
backgroundImage: `url("https://${cfg.baseUrl}/static/og-image.jpeg")`,
|
||||||
|
backgroundSize: "100% 100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
background: "radial-gradient(circle at center, transparent, rgba(0, 0, 0, 0.4) 70%)",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
height: "100%",
|
||||||
|
width: "100%",
|
||||||
|
flexDirection: "column",
|
||||||
|
justifyContent: "flex-start",
|
||||||
|
alignItems: "flex-start",
|
||||||
|
gap: "1.5rem",
|
||||||
|
paddingTop: "4rem",
|
||||||
|
paddingBottom: "4rem",
|
||||||
|
marginLeft: "4rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={`"https://${cfg.baseUrl}/static/icon.jpeg"`}
|
||||||
|
style={{
|
||||||
|
position: "relative",
|
||||||
|
backgroundClip: "border-box",
|
||||||
|
borderRadius: "6rem",
|
||||||
|
}}
|
||||||
|
width={80}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
textAlign: "left",
|
||||||
|
fontFamily: fonts[0].name,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<h2
|
||||||
|
style={{
|
||||||
|
color: cfg.theme.colors[colorScheme].light,
|
||||||
|
fontSize: "3rem",
|
||||||
|
fontWeight: 700,
|
||||||
|
marginRight: "4rem",
|
||||||
|
fontFamily: fonts[0].name,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
</h2>
|
||||||
|
<ul
|
||||||
|
style={{
|
||||||
|
color: cfg.theme.colors[colorScheme].gray,
|
||||||
|
gap: "1rem",
|
||||||
|
fontSize: "1.5rem",
|
||||||
|
fontFamily: fonts[1].name,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{Li.map((item, index) => {
|
||||||
|
if (item) {
|
||||||
|
return <li key={index}>{item}</li>
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
color: cfg.theme.colors[colorScheme].light,
|
||||||
|
fontSize: "1.5rem",
|
||||||
|
overflow: "hidden",
|
||||||
|
marginRight: "8rem",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
display: "-webkit-box",
|
||||||
|
WebkitLineClamp: 7,
|
||||||
|
WebkitBoxOrient: "vertical",
|
||||||
|
lineClamp: 7,
|
||||||
|
fontFamily: fonts[1].name,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{description}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -9,11 +9,12 @@ This plugin generates descriptions that are used as metadata for the HTML `head`
|
|||||||
If the frontmatter contains a `description` property, it is used (see [[authoring content#Syntax]]). Otherwise, the plugin will do its best to use the first few sentences of the content to reach the target description length.
|
If the frontmatter contains a `description` property, it is used (see [[authoring content#Syntax]]). Otherwise, the plugin will do its best to use the first few sentences of the content to reach the target description length.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
- `descriptionLength`: the maximum length of the generated description. Default is 150 characters. The cut off happens after the first _sentence_ that ends after the given length.
|
- `descriptionLength`: the maximum length of the generated description. Default is 150 characters. The cut off happens after the first _sentence_ that ends after the given length.
|
||||||
|
- `replaceExternalLinks`: If `true` (default), replace external links with their domain and path in the description (e.g. `https://domain.tld/some_page/another_page?query=hello&target=world` is replaced with `domain.tld/some_page/another_page`).
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ tags:
|
|||||||
This plugin filters content based on an explicit `publish` flag in the frontmatter, allowing only content that is explicitly marked for publication to pass through. It's the opt-in version of [[RemoveDrafts]]. See [[private pages]] for more information.
|
This plugin filters content based on an explicit `publish` flag in the frontmatter, allowing only content that is explicitly marked for publication to pass through. It's the opt-in version of [[RemoveDrafts]]. See [[private pages]] for more information.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin has no configuration options.
|
This plugin has no configuration options.
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
- Category: Emitter
|
- Category: Filter
|
||||||
- Function name: `Plugin.ExplicitPublish()`.
|
- Function name: `Plugin.ExplicitPublish()`.
|
||||||
- Source: [`quartz/plugins/filters/explicit.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/filters/explicit.ts).
|
- Source: [`quartz/plugins/filters/explicit.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/filters/explicit.ts).
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ This plugin generates index pages for folders, creating a listing page for each
|
|||||||
Example: [[advanced/|Advanced]]
|
Example: [[advanced/|Advanced]]
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin has no configuration options.
|
|
||||||
|
|
||||||
The pages are displayed using the `defaultListPageLayout` in `quartz.layouts.ts`. For the content, the `FolderContent` component is used. If you want to modify the layout, you must edit it directly (`quartz/components/pages/FolderContent.tsx`).
|
The pages are displayed using the `defaultListPageLayout` in `quartz.layouts.ts`. For the content, the `FolderContent` component is used. If you want to modify the layout, you must edit it directly (`quartz/components/pages/FolderContent.tsx`).
|
||||||
|
|
||||||
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
|
- `sort`: A function of type `(f1: QuartzPluginData, f2: QuartzPluginData) => number{:ts}` used to sort entries. Defaults to sorting by date and tie-breaking on lexographical order.
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
- Category: Emitter
|
- Category: Emitter
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ tags:
|
|||||||
This plugin parses the frontmatter of the page using the [gray-matter](https://github.com/jonschlinkert/gray-matter) library. See [[authoring content#Syntax]], [[Obsidian compatibility]] and [[OxHugo compatibility]] for more information.
|
This plugin parses the frontmatter of the page using the [gray-matter](https://github.com/jonschlinkert/gray-matter) library. See [[authoring content#Syntax]], [[Obsidian compatibility]] and [[OxHugo compatibility]] for more information.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
@@ -17,6 +17,54 @@ This plugin accepts the following configuration options:
|
|||||||
> [!warning]
|
> [!warning]
|
||||||
> This plugin must not be removed, otherwise Quartz will break.
|
> This plugin must not be removed, otherwise Quartz will break.
|
||||||
|
|
||||||
|
## List
|
||||||
|
|
||||||
|
Quartz supports the following frontmatter:
|
||||||
|
|
||||||
|
- title
|
||||||
|
- `title`
|
||||||
|
- description
|
||||||
|
- `description`
|
||||||
|
- permalink
|
||||||
|
- `permalink`
|
||||||
|
- comments
|
||||||
|
- `comments`
|
||||||
|
- lang
|
||||||
|
- `lang`
|
||||||
|
- publish
|
||||||
|
- `publish`
|
||||||
|
- draft
|
||||||
|
- `draft`
|
||||||
|
- enableToc
|
||||||
|
- `enableToc`
|
||||||
|
- tags
|
||||||
|
- `tags`
|
||||||
|
- `tag`
|
||||||
|
- aliases
|
||||||
|
- `aliases`
|
||||||
|
- `alias`
|
||||||
|
- cssclasses
|
||||||
|
- `cssclasses`
|
||||||
|
- `cssclass`
|
||||||
|
- socialDescription
|
||||||
|
- `socialDescription`
|
||||||
|
- socialImage
|
||||||
|
- `socialImage`
|
||||||
|
- `image`
|
||||||
|
- `cover`
|
||||||
|
- created
|
||||||
|
- `created`
|
||||||
|
- `date`
|
||||||
|
- modified
|
||||||
|
- `modified`
|
||||||
|
- `lastmod`
|
||||||
|
- `updated`
|
||||||
|
- `last-modified`
|
||||||
|
- published
|
||||||
|
- `published`
|
||||||
|
- `publishDate`
|
||||||
|
- `date`
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
- Category: Transformer
|
- Category: Transformer
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ This plugin enhances Markdown processing to support GitHub Flavored Markdown (GF
|
|||||||
In addition, this plugin adds optional features for typographic refinement (such as converting straight quotes to curly quotes, dashes to en-dashes/em-dashes, and ellipses) and automatic heading links as a symbol that appears next to the heading on hover.
|
In addition, this plugin adds optional features for typographic refinement (such as converting straight quotes to curly quotes, dashes to en-dashes/em-dashes, and ellipses) and automatic heading links as a symbol that appears next to the heading on hover.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ tags:
|
|||||||
This plugin automatically converts single line breaks in Markdown text into hard line breaks in the HTML output. This plugin is not enabled by default as this doesn't follow the semantics of actual Markdown but you may enable it if you'd like parity with [[Obsidian compatibility|Obsidian]].
|
This plugin automatically converts single line breaks in Markdown text into hard line breaks in the HTML output. This plugin is not enabled by default as this doesn't follow the semantics of actual Markdown but you may enable it if you'd like parity with [[Obsidian compatibility|Obsidian]].
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin has no configuration options.
|
This plugin has no configuration options.
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,16 @@ tags:
|
|||||||
This plugin adds LaTeX support to Quartz. See [[features/Latex|Latex]] for more information.
|
This plugin adds LaTeX support to Quartz. See [[features/Latex|Latex]] for more information.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
- `renderEngine`: the engine to use to render LaTeX equations. Can be `"katex"` for [KaTeX](https://katex.org/) or `"mathjax"` for [MathJax](https://www.mathjax.org/) [SVG rendering](https://docs.mathjax.org/en/latest/output/svg.html). Defaults to KaTeX.
|
- `renderEngine`: the engine to use to render LaTeX equations. Can be `"katex"` for [KaTeX](https://katex.org/), `"mathjax"` for [MathJax](https://www.mathjax.org/) [SVG rendering](https://docs.mathjax.org/en/latest/output/svg.html), or `"typst"` for [Typst](https://typst.app/) (a new way to compose LaTeX equation). Defaults to KaTeX.
|
||||||
|
- `customMacros`: custom macros for all LaTeX blocks. It takes the form of a key-value pair where the key is a new command name and the value is the expansion of the macro. For example: `{"\\R": "\\mathbb{R}"}`
|
||||||
|
|
||||||
|
> [!note] Typst support
|
||||||
|
>
|
||||||
|
> Currently, typst doesn't support inline-math
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ tags:
|
|||||||
This plugin emits a 404 (Not Found) page for broken or non-existent URLs.
|
This plugin emits a 404 (Not Found) page for broken or non-existent URLs.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin has no configuration options.
|
This plugin has no configuration options.
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ tags:
|
|||||||
This plugin provides support for [[Obsidian compatibility]].
|
This plugin provides support for [[Obsidian compatibility]].
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ This plugin accepts the following configuration options:
|
|||||||
- `parseArrows`: If `true` (default), transforms arrow symbols into their HTML character equivalents.
|
- `parseArrows`: If `true` (default), transforms arrow symbols into their HTML character equivalents.
|
||||||
- `parseBlockReferences`: If `true` (default), handles block references, linking to specific content blocks.
|
- `parseBlockReferences`: If `true` (default), handles block references, linking to specific content blocks.
|
||||||
- `enableInHtmlEmbed`: If `true`, allows embedding of content directly within HTML. Defaults to `false`.
|
- `enableInHtmlEmbed`: If `true`, allows embedding of content directly within HTML. Defaults to `false`.
|
||||||
- `enableYouTubeEmbed`: If `true` (default), enables the embedding of YouTube videos using external image Markdown syntax.
|
- `enableYouTubeEmbed`: If `true` (default), enables the embedding of YouTube videos and playlists using external image Markdown syntax.
|
||||||
- `enableVideoEmbed`: If `true` (default), enables the embedding of video files.
|
- `enableVideoEmbed`: If `true` (default), enables the embedding of video files.
|
||||||
- `enableCheckbox`: If `true`, adds support for interactive checkboxes in content. Defaults to `false`.
|
- `enableCheckbox`: If `true`, adds support for interactive checkboxes in content. Defaults to `false`.
|
||||||
|
|
||||||
@@ -31,4 +31,4 @@ This plugin accepts the following configuration options:
|
|||||||
|
|
||||||
- Category: Transformer
|
- Category: Transformer
|
||||||
- Function name: `Plugin.ObsidianFlavoredMarkdown()`.
|
- Function name: `Plugin.ObsidianFlavoredMarkdown()`.
|
||||||
- Source: [`quartz/plugins/transformers/toc.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/toc.ts).
|
- Source: [`quartz/plugins/transformers/ofm.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/ofm.ts)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ tags:
|
|||||||
This plugin provides support for [ox-hugo](https://github.com/kaushalmodi/ox-hugo) compatibility. See [[OxHugo compatibility]] for more information.
|
This plugin provides support for [ox-hugo](https://github.com/kaushalmodi/ox-hugo) compatibility. See [[OxHugo compatibility]] for more information.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ tags:
|
|||||||
This plugin filters out content from your vault, so that only finalized content is made available. This prevents [[private pages]] from being published. By default, it filters out all pages with `draft: true` in the frontmatter and leaves all other pages intact.
|
This plugin filters out content from your vault, so that only finalized content is made available. This prevents [[private pages]] from being published. By default, it filters out all pages with `draft: true` in the frontmatter and leaves all other pages intact.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin has no configuration options.
|
This plugin has no configuration options.
|
||||||
|
|
||||||
|
|||||||
26
docs/plugins/RoamFlavoredMarkdown.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
title: RoamFlavoredMarkdown
|
||||||
|
tags:
|
||||||
|
- plugin/transformer
|
||||||
|
---
|
||||||
|
|
||||||
|
This plugin provides support for [Roam Research](https://roamresearch.com) compatibility. See [[Roam Research Compatibility]] for more information.
|
||||||
|
|
||||||
|
> [!note]
|
||||||
|
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
|
- `orComponent`: If `true` (default), converts Roam `{{ or:ONE|TWO|THREE }}` shortcodes into HTML Dropdown options.
|
||||||
|
- `TODOComponent`: If `true` (default), converts Roam `{{[[TODO]]}}` shortcodes into HTML check boxes.
|
||||||
|
- `DONEComponent`: If `true` (default), converts Roam `{{[[DONE]]}}` shortcodes into checked HTML check boxes.
|
||||||
|
- `videoComponent`: If `true` (default), converts Roam `{{[[video]]:URL}}` shortcodes into embeded HTML video.
|
||||||
|
- `audioComponent`: If `true` (default), converts Roam `{{[[audio]]:URL}}` shortcodes into embeded HTML audio.
|
||||||
|
- `pdfComponent`: If `true` (default), converts Roam `{{[[pdf]]:URL}}` shortcodes into embeded HTML PDF viewer.
|
||||||
|
- `blockquoteComponent`: If `true` (default), converts Roam `{{[[>]]}}` shortcodes into Quartz blockquotes.
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
- Category: Transformer
|
||||||
|
- Function name: `Plugin.RoamFlavoredMarkdown()`.
|
||||||
|
- Source: [`quartz/plugins/transformers/roam.ts`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/transformers/roam.ts).
|
||||||
@@ -10,7 +10,7 @@ This plugin emits all static resources needed by Quartz. This is used, for examp
|
|||||||
> This is different from [[Assets]]. The resources from the [[Static]] plugin are located under `quartz/static`, whereas [[Assets]] renders all static resources under `content` and is used for images, videos, audio, etc. that are directly referenced by your markdown content.
|
> This is different from [[Assets]]. The resources from the [[Static]] plugin are located under `quartz/static`, whereas [[Assets]] renders all static resources under `content` and is used for images, videos, audio, etc. that are directly referenced by your markdown content.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin has no configuration options.
|
This plugin has no configuration options.
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ tags:
|
|||||||
This plugin is used to add syntax highlighting to code blocks in Quartz. See [[syntax highlighting]] for more information.
|
This plugin is used to add syntax highlighting to code blocks in Quartz. See [[syntax highlighting]] for more information.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ tags:
|
|||||||
This plugin generates a table of contents (TOC) for Markdown documents. See [[table of contents]] for more information.
|
This plugin generates a table of contents (TOC) for Markdown documents. See [[table of contents]] for more information.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin accepts the following configuration options:
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,16 @@ tags:
|
|||||||
This plugin emits dedicated pages for each tag used in the content. See [[folder and tag listings]] for more information.
|
This plugin emits dedicated pages for each tag used in the content. See [[folder and tag listings]] for more information.
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> For information on how to add, remove or configure plugins, see the [[Configuration#Plugins|Configuration]] page.
|
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||||
|
|
||||||
This plugin has no configuration options.
|
|
||||||
|
|
||||||
The pages are displayed using the `defaultListPageLayout` in `quartz.layouts.ts`. For the content, the `TagContent` component is used. If you want to modify the layout, you must edit it directly (`quartz/components/pages/TagContent.tsx`).
|
The pages are displayed using the `defaultListPageLayout` in `quartz.layouts.ts`. For the content, the `TagContent` component is used. If you want to modify the layout, you must edit it directly (`quartz/components/pages/TagContent.tsx`).
|
||||||
|
|
||||||
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
|
- `sort`: A function of type `(f1: QuartzPluginData, f2: QuartzPluginData) => number{:ts}` used to sort entries. Defaults to sorting by date and tie-breaking on lexographical order.
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
- Category: Emitter
|
- Category: Emitter
|
||||||
- Function name: `Plugin.AliasRedirects()`.
|
- Function name: `Plugin.TagPage()`.
|
||||||
- Source: [`quartz/plugins/emitters/tagPage.tsx`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/tagPage.tsx).
|
- Source: [`quartz/plugins/emitters/tagPage.tsx`](https://github.com/jackyzha0/quartz/blob/v4/quartz/plugins/emitters/tagPage.tsx).
|
||||||
|
|||||||
@@ -7,24 +7,28 @@ Want to see what Quartz can do? Here are some cool community gardens:
|
|||||||
- [Quartz Documentation (this site!)](https://quartz.jzhao.xyz/)
|
- [Quartz Documentation (this site!)](https://quartz.jzhao.xyz/)
|
||||||
- [Jacky Zhao's Garden](https://jzhao.xyz/)
|
- [Jacky Zhao's Garden](https://jzhao.xyz/)
|
||||||
- [Socratica Toolbox](https://toolbox.socratica.info/)
|
- [Socratica Toolbox](https://toolbox.socratica.info/)
|
||||||
- [oldwinter の数字花园](https://garden.oldwinter.top/)
|
- [Morrowind Modding Wiki](https://morrowind-modding.github.io/)
|
||||||
- [Aaron Pham's Garden](https://aarnphm.xyz/)
|
- [Aaron Pham's Garden](https://aarnphm.xyz/)
|
||||||
- [The Quantum Garden](https://quantumgardener.blog/)
|
- [The Pond](https://turntrout.com/welcome)
|
||||||
- [Abhijeet's Math Wiki](https://abhmul.github.io/quartz/Math-Wiki/)
|
- [Pelayo Arbues' Notes](https://pelayoarbues.com/)
|
||||||
- [Matt Dunn's Second Brain](https://mattdunn.info/)
|
- [Stanford CME 302 Numerical Linear Algebra](https://ericdarve.github.io/NLA/)
|
||||||
- [Pelayo Arbues' Notes](https://pelayoarbues.github.io/)
|
- [A Pattern Language - Christopher Alexander (Architecture)](https://patternlanguage.cc/)
|
||||||
- [Vince Imbat's Talahardin](https://vinceimbat.com/)
|
- [oldwinter の数字花园](https://garden.oldwinter.top/)
|
||||||
|
- [Eilleen's Everything Notebook](https://quartz.eilleeenz.com/)
|
||||||
- [🧠🌳 Chad's Mind Garden](https://www.chadly.net/)
|
- [🧠🌳 Chad's Mind Garden](https://www.chadly.net/)
|
||||||
- [Pedro MC Fernandes's Topo da Mente](https://www.pmcf.xyz/topo-da-mente/)
|
- [Pedro MC Fernandes's Topo da Mente](https://www.pmcf.xyz/topo-da-mente/)
|
||||||
- [Mau Camargo's Notkesto](https://notes.camargomau.com/)
|
- [Mau Camargo's Notkesto](https://notes.camargomau.com/)
|
||||||
- [Caicai's Novels](https://imoko.cc/blog/caicai/)
|
|
||||||
- [🌊 Collapsed Wave](https://collapsedwave.com/)
|
|
||||||
- [Sideny's 3D Artist's Handbook](https://sidney-eliot.github.io/3d-artists-handbook/)
|
- [Sideny's 3D Artist's Handbook](https://sidney-eliot.github.io/3d-artists-handbook/)
|
||||||
- [Mike's AI Garden 🤖🪴](https://mwalton.me/)
|
|
||||||
- [Brandon Boswell's Garden](https://brandonkboswell.com)
|
- [Brandon Boswell's Garden](https://brandonkboswell.com)
|
||||||
- [Scaling Synthesis - A hypertext research notebook](https://scalingsynthesis.com/)
|
- [Scaling Synthesis - A hypertext research notebook](https://scalingsynthesis.com/)
|
||||||
|
- [Simon's Second Brain: Crafted, Curated, Connected, Compounded](https://brain.ssp.sh/)
|
||||||
|
- [Data Engineering Vault: A Second Brain Knowledge Network](https://vault.ssp.sh/)
|
||||||
- [Data Dictionary 🧠](https://glossary.airbyte.com/)
|
- [Data Dictionary 🧠](https://glossary.airbyte.com/)
|
||||||
- [sspaeti.com's Second Brain](https://brain.sspaeti.com/)
|
|
||||||
- [🪴Aster's notebook](https://notes.asterhu.com)
|
- [🪴Aster's notebook](https://notes.asterhu.com)
|
||||||
|
- [Gatekeeper Wiki](https://www.gatekeeper.wiki)
|
||||||
If you want to see your own on here, submit a [Pull Request adding yourself to this file](https://github.com/jackyzha0/quartz/blob/v4/docs/showcase.md)!
|
- [Ellie's Notes](https://ellie.wtf)
|
||||||
|
- [🥷🏻🌳🍃 Computer Science & Thinkering Garden](https://notes.yxy.ninja)
|
||||||
|
- [Eledah's Crystalline](https://blog.eledah.ir/)
|
||||||
|
- [🌓 Projects & Privacy - FOSS, tech, law](https://be-far.com)
|
||||||
|
- [Zen Browser Docs](https://docs.zen-browser.app)
|
||||||
|
- [🪴8cat life](https://8cat.life)
|
||||||
|
|||||||
4
globals.d.ts
vendored
@@ -4,6 +4,10 @@ export declare global {
|
|||||||
type: K,
|
type: K,
|
||||||
listener: (this: Document, ev: CustomEventMap[K]) => void,
|
listener: (this: Document, ev: CustomEventMap[K]) => void,
|
||||||
): void
|
): void
|
||||||
|
removeEventListener<K extends keyof CustomEventMap>(
|
||||||
|
type: K,
|
||||||
|
listener: (this: Document, ev: CustomEventMap[K]) => void,
|
||||||
|
): void
|
||||||
dispatchEvent<K extends keyof CustomEventMap>(ev: CustomEventMap[K] | UIEvent): void
|
dispatchEvent<K extends keyof CustomEventMap>(ev: CustomEventMap[K] | UIEvent): void
|
||||||
}
|
}
|
||||||
interface Window {
|
interface Window {
|
||||||
|
|||||||
2
index.d.ts
vendored
@@ -5,8 +5,10 @@ declare module "*.scss" {
|
|||||||
|
|
||||||
// dom custom event
|
// dom custom event
|
||||||
interface CustomEventMap {
|
interface CustomEventMap {
|
||||||
|
prenav: CustomEvent<{}>
|
||||||
nav: CustomEvent<{ url: FullSlug }>
|
nav: CustomEvent<{ url: FullSlug }>
|
||||||
themechange: CustomEvent<{ theme: "light" | "dark" }>
|
themechange: CustomEvent<{ theme: "light" | "dark" }>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ContentIndex = Record<FullSlug, ContentDetails>
|
||||||
declare const fetchData: Promise<ContentIndex>
|
declare const fetchData: Promise<ContentIndex>
|
||||||
|
|||||||
3857
package-lock.json
generated
90
package.json
@@ -2,7 +2,7 @@
|
|||||||
"name": "@jackyzha0/quartz",
|
"name": "@jackyzha0/quartz",
|
||||||
"description": "🌱 publish your digital garden and notes as a website",
|
"description": "🌱 publish your digital garden and notes as a website",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "4.2.3",
|
"version": "4.4.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"author": "jackyzha0 <j.zhao2k19@gmail.com>",
|
"author": "jackyzha0 <j.zhao2k19@gmail.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -12,15 +12,16 @@
|
|||||||
"url": "https://github.com/jackyzha0/quartz.git"
|
"url": "https://github.com/jackyzha0/quartz.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"quartz": "./quartz/bootstrap-cli.mjs",
|
||||||
"docs": "npx quartz build --serve -d docs",
|
"docs": "npx quartz build --serve -d docs",
|
||||||
"check": "tsc --noEmit && npx prettier . --check",
|
"check": "tsc --noEmit && npx prettier . --check",
|
||||||
"format": "npx prettier . --write",
|
"format": "npx prettier . --write",
|
||||||
"test": "tsx ./quartz/util/path.test.ts && tsx ./quartz/depgraph.test.ts",
|
"test": "tsx --test",
|
||||||
"profile": "0x -D prof ./quartz/bootstrap-cli.mjs build --concurrency=1"
|
"profile": "0x -D prof ./quartz/bootstrap-cli.mjs build --concurrency=1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"npm": ">=9.3.1",
|
"npm": ">=9.3.1",
|
||||||
"node": ">=18.14"
|
"node": ">=20"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"site generator",
|
"site generator",
|
||||||
@@ -34,75 +35,80 @@
|
|||||||
"quartz": "./quartz/bootstrap-cli.mjs"
|
"quartz": "./quartz/bootstrap-cli.mjs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@clack/prompts": "^0.7.0",
|
"@clack/prompts": "^0.10.0",
|
||||||
"@floating-ui/dom": "^1.6.3",
|
"@floating-ui/dom": "^1.6.13",
|
||||||
"@napi-rs/simple-git": "0.1.16",
|
"@myriaddreamin/rehype-typst": "^0.5.4",
|
||||||
"async-mutex": "^0.4.1",
|
"@napi-rs/simple-git": "0.1.19",
|
||||||
"chalk": "^5.3.0",
|
"@tweenjs/tween.js": "^25.0.0",
|
||||||
"chokidar": "^3.5.3",
|
"async-mutex": "^0.5.0",
|
||||||
|
"chalk": "^5.4.1",
|
||||||
|
"chokidar": "^4.0.3",
|
||||||
"cli-spinner": "^0.2.10",
|
"cli-spinner": "^0.2.10",
|
||||||
"d3": "^7.8.5",
|
"d3": "^7.9.0",
|
||||||
"esbuild-sass-plugin": "^2.16.1",
|
"esbuild-sass-plugin": "^3.3.1",
|
||||||
"flexsearch": "0.7.43",
|
"flexsearch": "0.7.43",
|
||||||
"github-slugger": "^2.0.0",
|
"github-slugger": "^2.0.0",
|
||||||
"globby": "^14.0.1",
|
"globby": "^14.1.0",
|
||||||
"gray-matter": "^4.0.3",
|
"gray-matter": "^4.0.3",
|
||||||
"hast-util-to-html": "^9.0.0",
|
"hast-util-to-html": "^9.0.5",
|
||||||
"hast-util-to-jsx-runtime": "^2.3.0",
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
||||||
"hast-util-to-string": "^3.0.0",
|
"hast-util-to-string": "^3.0.1",
|
||||||
"is-absolute-url": "^4.0.1",
|
"is-absolute-url": "^4.0.1",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"lightningcss": "^1.23.0",
|
"lightningcss": "^1.29.2",
|
||||||
"mdast-util-find-and-replace": "^3.0.1",
|
"mdast-util-find-and-replace": "^3.0.2",
|
||||||
"mdast-util-to-hast": "^13.1.0",
|
"mdast-util-to-hast": "^13.2.0",
|
||||||
"mdast-util-to-string": "^4.0.0",
|
"mdast-util-to-string": "^4.0.0",
|
||||||
"micromorph": "^0.4.5",
|
"micromorph": "^0.4.5",
|
||||||
"preact": "^10.19.5",
|
"pixi.js": "^8.8.1",
|
||||||
"preact-render-to-string": "^6.3.1",
|
"preact": "^10.26.4",
|
||||||
|
"preact-render-to-string": "^6.5.13",
|
||||||
"pretty-bytes": "^6.1.1",
|
"pretty-bytes": "^6.1.1",
|
||||||
"pretty-time": "^1.1.0",
|
"pretty-time": "^1.1.0",
|
||||||
"reading-time": "^1.5.0",
|
"reading-time": "^1.5.0",
|
||||||
"rehype-autolink-headings": "^7.1.0",
|
"rehype-autolink-headings": "^7.1.0",
|
||||||
"rehype-katex": "^7.0.0",
|
"rehype-citation": "^2.2.2",
|
||||||
"rehype-mathjax": "^6.0.0",
|
"rehype-katex": "^7.0.1",
|
||||||
"rehype-pretty-code": "^0.13.0",
|
"rehype-mathjax": "^7.1.0",
|
||||||
|
"rehype-pretty-code": "^0.14.0",
|
||||||
"rehype-raw": "^7.0.0",
|
"rehype-raw": "^7.0.0",
|
||||||
"rehype-slug": "^6.0.0",
|
"rehype-slug": "^6.0.0",
|
||||||
"remark": "^15.0.1",
|
"remark": "^15.0.1",
|
||||||
"remark-breaks": "^4.0.0",
|
"remark-breaks": "^4.0.0",
|
||||||
"remark-frontmatter": "^5.0.0",
|
"remark-frontmatter": "^5.0.0",
|
||||||
"remark-gfm": "^4.0.0",
|
"remark-gfm": "^4.0.1",
|
||||||
"remark-math": "^6.0.0",
|
"remark-math": "^6.0.0",
|
||||||
"remark-parse": "^11.0.0",
|
"remark-parse": "^11.0.0",
|
||||||
"remark-rehype": "^11.1.0",
|
"remark-rehype": "^11.1.1",
|
||||||
"remark-smartypants": "^2.0.0",
|
"remark-smartypants": "^3.0.2",
|
||||||
"rfdc": "^1.3.1",
|
"rfdc": "^1.4.1",
|
||||||
"rimraf": "^5.0.5",
|
"rimraf": "^6.0.1",
|
||||||
"serve-handler": "^6.1.5",
|
"satori": "^0.12.1",
|
||||||
"shiki": "^1.1.6",
|
"serve-handler": "^6.1.6",
|
||||||
|
"sharp": "^0.33.5",
|
||||||
|
"shiki": "^1.26.2",
|
||||||
"source-map-support": "^0.5.21",
|
"source-map-support": "^0.5.21",
|
||||||
"to-vfile": "^8.0.0",
|
"to-vfile": "^8.0.0",
|
||||||
"toml": "^3.0.0",
|
"toml": "^3.0.0",
|
||||||
"unified": "^11.0.4",
|
"unified": "^11.0.5",
|
||||||
"unist-util-visit": "^5.0.0",
|
"unist-util-visit": "^5.0.0",
|
||||||
"vfile": "^6.0.1",
|
"vfile": "^6.0.3",
|
||||||
"workerpool": "^9.1.0",
|
"workerpool": "^9.2.0",
|
||||||
"ws": "^8.15.1",
|
"ws": "^8.18.1",
|
||||||
"yargs": "^17.7.2"
|
"yargs": "^17.7.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/cli-spinner": "^0.2.3",
|
|
||||||
"@types/d3": "^7.4.3",
|
"@types/d3": "^7.4.3",
|
||||||
"@types/hast": "^3.0.4",
|
"@types/hast": "^3.0.4",
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/node": "^20.11.19",
|
"@types/node": "^22.13.10",
|
||||||
"@types/pretty-time": "^1.1.5",
|
"@types/pretty-time": "^1.1.5",
|
||||||
"@types/source-map-support": "^0.5.10",
|
"@types/source-map-support": "^0.5.10",
|
||||||
"@types/ws": "^8.5.10",
|
"@types/ws": "^8.18.0",
|
||||||
"@types/yargs": "^17.0.32",
|
"@types/yargs": "^17.0.33",
|
||||||
"esbuild": "^0.19.9",
|
"esbuild": "^0.25.1",
|
||||||
"prettier": "^3.2.4",
|
"prettier": "^3.5.3",
|
||||||
"tsx": "^4.7.1",
|
"tsx": "^4.19.3",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.8.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,14 @@ import { QuartzConfig } from "./quartz/cfg"
|
|||||||
import * as Plugin from "./quartz/plugins"
|
import * as Plugin from "./quartz/plugins"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Quartz 4.0 Configuration
|
* Quartz 4 Configuration
|
||||||
*
|
*
|
||||||
* See https://quartz.jzhao.xyz/configuration for more information.
|
* See https://quartz.jzhao.xyz/configuration for more information.
|
||||||
*/
|
*/
|
||||||
const config: QuartzConfig = {
|
const config: QuartzConfig = {
|
||||||
configuration: {
|
configuration: {
|
||||||
pageTitle: "🪴 Quartz 4.0",
|
pageTitle: "Quartz 4",
|
||||||
|
pageTitleSuffix: "",
|
||||||
enableSPA: true,
|
enableSPA: true,
|
||||||
enablePopovers: true,
|
enablePopovers: true,
|
||||||
analytics: {
|
analytics: {
|
||||||
@@ -19,6 +20,7 @@ const config: QuartzConfig = {
|
|||||||
ignorePatterns: ["private", "templates", ".obsidian"],
|
ignorePatterns: ["private", "templates", ".obsidian"],
|
||||||
defaultDateType: "created",
|
defaultDateType: "created",
|
||||||
theme: {
|
theme: {
|
||||||
|
fontOrigin: "googleFonts",
|
||||||
cdnCaching: true,
|
cdnCaching: true,
|
||||||
typography: {
|
typography: {
|
||||||
header: "Schibsted Grotesk",
|
header: "Schibsted Grotesk",
|
||||||
@@ -35,6 +37,7 @@ const config: QuartzConfig = {
|
|||||||
secondary: "#284b63",
|
secondary: "#284b63",
|
||||||
tertiary: "#84a59d",
|
tertiary: "#84a59d",
|
||||||
highlight: "rgba(143, 159, 169, 0.15)",
|
highlight: "rgba(143, 159, 169, 0.15)",
|
||||||
|
textHighlight: "#fff23688",
|
||||||
},
|
},
|
||||||
darkMode: {
|
darkMode: {
|
||||||
light: "#161618",
|
light: "#161618",
|
||||||
@@ -45,6 +48,7 @@ const config: QuartzConfig = {
|
|||||||
secondary: "#7b97aa",
|
secondary: "#7b97aa",
|
||||||
tertiary: "#84a59d",
|
tertiary: "#84a59d",
|
||||||
highlight: "rgba(143, 159, 169, 0.15)",
|
highlight: "rgba(143, 159, 169, 0.15)",
|
||||||
|
textHighlight: "#b3aa0288",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -55,7 +59,6 @@ const config: QuartzConfig = {
|
|||||||
Plugin.CreatedModifiedDate({
|
Plugin.CreatedModifiedDate({
|
||||||
priority: ["frontmatter", "filesystem"],
|
priority: ["frontmatter", "filesystem"],
|
||||||
}),
|
}),
|
||||||
Plugin.Latex({ renderEngine: "katex" }),
|
|
||||||
Plugin.SyntaxHighlighting({
|
Plugin.SyntaxHighlighting({
|
||||||
theme: {
|
theme: {
|
||||||
light: "github-light",
|
light: "github-light",
|
||||||
@@ -68,11 +71,12 @@ const config: QuartzConfig = {
|
|||||||
Plugin.TableOfContents(),
|
Plugin.TableOfContents(),
|
||||||
Plugin.CrawlLinks({ markdownLinkResolution: "shortest" }),
|
Plugin.CrawlLinks({ markdownLinkResolution: "shortest" }),
|
||||||
Plugin.Description(),
|
Plugin.Description(),
|
||||||
|
Plugin.Latex({ renderEngine: "katex" }),
|
||||||
],
|
],
|
||||||
filters: [Plugin.RemoveDrafts()],
|
filters: [Plugin.RemoveDrafts()],
|
||||||
emitters: [
|
emitters: [
|
||||||
Plugin.AliasRedirects(),
|
Plugin.AliasRedirects(),
|
||||||
Plugin.ComponentResources({ fontOrigin: "googleFonts" }),
|
Plugin.ComponentResources(),
|
||||||
Plugin.ContentPage(),
|
Plugin.ContentPage(),
|
||||||
Plugin.FolderPage(),
|
Plugin.FolderPage(),
|
||||||
Plugin.TagPage(),
|
Plugin.TagPage(),
|
||||||
@@ -83,6 +87,8 @@ const config: QuartzConfig = {
|
|||||||
Plugin.Assets(),
|
Plugin.Assets(),
|
||||||
Plugin.Static(),
|
Plugin.Static(),
|
||||||
Plugin.NotFoundPage(),
|
Plugin.NotFoundPage(),
|
||||||
|
// Comment out CustomOgImages to speed up build time
|
||||||
|
Plugin.CustomOgImages(),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import * as Component from "./quartz/components"
|
|||||||
export const sharedPageComponents: SharedLayout = {
|
export const sharedPageComponents: SharedLayout = {
|
||||||
head: Component.Head(),
|
head: Component.Head(),
|
||||||
header: [],
|
header: [],
|
||||||
|
afterBody: [],
|
||||||
footer: Component.Footer({
|
footer: Component.Footer({
|
||||||
links: {
|
links: {
|
||||||
GitHub: "https://github.com/jackyzha0/quartz",
|
GitHub: "https://github.com/jackyzha0/quartz",
|
||||||
@@ -24,9 +25,16 @@ export const defaultContentPageLayout: PageLayout = {
|
|||||||
left: [
|
left: [
|
||||||
Component.PageTitle(),
|
Component.PageTitle(),
|
||||||
Component.MobileOnly(Component.Spacer()),
|
Component.MobileOnly(Component.Spacer()),
|
||||||
Component.Search(),
|
Component.Flex({
|
||||||
Component.Darkmode(),
|
components: [
|
||||||
Component.DesktopOnly(Component.Explorer()),
|
{
|
||||||
|
Component: Component.Search(),
|
||||||
|
grow: true,
|
||||||
|
},
|
||||||
|
{ Component: Component.Darkmode() },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
Component.Explorer(),
|
||||||
],
|
],
|
||||||
right: [
|
right: [
|
||||||
Component.Graph(),
|
Component.Graph(),
|
||||||
@@ -41,9 +49,16 @@ export const defaultListPageLayout: PageLayout = {
|
|||||||
left: [
|
left: [
|
||||||
Component.PageTitle(),
|
Component.PageTitle(),
|
||||||
Component.MobileOnly(Component.Spacer()),
|
Component.MobileOnly(Component.Spacer()),
|
||||||
Component.Search(),
|
Component.Flex({
|
||||||
Component.Darkmode(),
|
components: [
|
||||||
Component.DesktopOnly(Component.Explorer()),
|
{
|
||||||
|
Component: Component.Search(),
|
||||||
|
grow: true,
|
||||||
|
},
|
||||||
|
{ Component: Component.Darkmode() },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
Component.Explorer(),
|
||||||
],
|
],
|
||||||
right: [],
|
right: [],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env -S node --no-deprecation
|
||||||
import yargs from "yargs"
|
import yargs from "yargs"
|
||||||
import { hideBin } from "yargs/helpers"
|
import { hideBin } from "yargs/helpers"
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import workerpool from "workerpool"
|
import workerpool from "workerpool"
|
||||||
const cacheFile = "./.quartz-cache/transpiled-worker.mjs"
|
const cacheFile = "./.quartz-cache/transpiled-worker.mjs"
|
||||||
const { parseFiles } = await import(cacheFile)
|
const { parseMarkdown, processHtml } = await import(cacheFile)
|
||||||
workerpool.worker({
|
workerpool.worker({
|
||||||
parseFiles,
|
parseMarkdown,
|
||||||
|
processHtml,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { options } from "./util/sourcemap"
|
|||||||
import { Mutex } from "async-mutex"
|
import { Mutex } from "async-mutex"
|
||||||
import DepGraph from "./depgraph"
|
import DepGraph from "./depgraph"
|
||||||
import { getStaticResourcesFromPlugins } from "./plugins"
|
import { getStaticResourcesFromPlugins } from "./plugins"
|
||||||
|
import { randomIdNonSecure } from "./util/random"
|
||||||
|
|
||||||
type Dependencies = Record<string, DepGraph<FilePath> | null>
|
type Dependencies = Record<string, DepGraph<FilePath> | null>
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@ type FileEvent = "add" | "change" | "delete"
|
|||||||
|
|
||||||
async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
|
async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
|
||||||
const ctx: BuildCtx = {
|
const ctx: BuildCtx = {
|
||||||
|
buildId: randomIdNonSecure(),
|
||||||
argv,
|
argv,
|
||||||
cfg,
|
cfg,
|
||||||
allSlugs: [],
|
allSlugs: [],
|
||||||
@@ -134,9 +136,9 @@ async function startServing(
|
|||||||
|
|
||||||
const buildFromEntry = argv.fastRebuild ? partialRebuildFromEntrypoint : rebuildFromEntrypoint
|
const buildFromEntry = argv.fastRebuild ? partialRebuildFromEntrypoint : rebuildFromEntrypoint
|
||||||
watcher
|
watcher
|
||||||
.on("add", (fp) => buildFromEntry(fp, "add", clientRefresh, buildData))
|
.on("add", (fp) => buildFromEntry(fp as string, "add", clientRefresh, buildData))
|
||||||
.on("change", (fp) => buildFromEntry(fp, "change", clientRefresh, buildData))
|
.on("change", (fp) => buildFromEntry(fp as string, "change", clientRefresh, buildData))
|
||||||
.on("unlink", (fp) => buildFromEntry(fp, "delete", clientRefresh, buildData))
|
.on("unlink", (fp) => buildFromEntry(fp as string, "delete", clientRefresh, buildData))
|
||||||
|
|
||||||
return async () => {
|
return async () => {
|
||||||
await watcher.close()
|
await watcher.close()
|
||||||
@@ -157,10 +159,13 @@ async function partialRebuildFromEntrypoint(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildStart = new Date().getTime()
|
const buildId = randomIdNonSecure()
|
||||||
buildData.lastBuildMs = buildStart
|
ctx.buildId = buildId
|
||||||
|
buildData.lastBuildMs = new Date().getTime()
|
||||||
const release = await mut.acquire()
|
const release = await mut.acquire()
|
||||||
if (buildData.lastBuildMs > buildStart) {
|
|
||||||
|
// if there's another build after us, release and let them do it
|
||||||
|
if (ctx.buildId !== buildId) {
|
||||||
release()
|
release()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -245,15 +250,25 @@ async function partialRebuildFromEntrypoint(
|
|||||||
([_node, vfile]) => !toRemove.has(vfile.data.filePath!),
|
([_node, vfile]) => !toRemove.has(vfile.data.filePath!),
|
||||||
)
|
)
|
||||||
|
|
||||||
const emittedFps = await emitter.emit(ctx, files, staticResources)
|
const emitted = await emitter.emit(ctx, files, staticResources)
|
||||||
|
if (Symbol.asyncIterator in emitted) {
|
||||||
if (ctx.argv.verbose) {
|
// Async generator case
|
||||||
for (const file of emittedFps) {
|
for await (const file of emitted) {
|
||||||
console.log(`[emit:${emitter.name}] ${file}`)
|
emittedFiles++
|
||||||
|
if (ctx.argv.verbose) {
|
||||||
|
console.log(`[emit:${emitter.name}] ${file}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Array case
|
||||||
|
emittedFiles += emitted.length
|
||||||
|
if (ctx.argv.verbose) {
|
||||||
|
for (const file of emitted) {
|
||||||
|
console.log(`[emit:${emitter.name}] ${file}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emittedFiles += emittedFps.length
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,15 +290,24 @@ async function partialRebuildFromEntrypoint(
|
|||||||
.filter((file) => !toRemove.has(file))
|
.filter((file) => !toRemove.has(file))
|
||||||
.map((file) => contentMap.get(file)!)
|
.map((file) => contentMap.get(file)!)
|
||||||
|
|
||||||
const emittedFps = await emitter.emit(ctx, upstreamContent, staticResources)
|
const emitted = await emitter.emit(ctx, upstreamContent, staticResources)
|
||||||
|
if (Symbol.asyncIterator in emitted) {
|
||||||
if (ctx.argv.verbose) {
|
// Async generator case
|
||||||
for (const file of emittedFps) {
|
for await (const file of emitted) {
|
||||||
console.log(`[emit:${emitter.name}] ${file}`)
|
emittedFiles++
|
||||||
|
if (ctx.argv.verbose) {
|
||||||
|
console.log(`[emit:${emitter.name}] ${file}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Array case
|
||||||
|
emittedFiles += emitted.length
|
||||||
|
if (ctx.argv.verbose) {
|
||||||
|
for (const file of emitted) {
|
||||||
|
console.log(`[emit:${emitter.name}] ${file}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emittedFiles += emittedFps.length
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,6 +333,8 @@ async function partialRebuildFromEntrypoint(
|
|||||||
}
|
}
|
||||||
await rimraf([...destinationsToDelete])
|
await rimraf([...destinationsToDelete])
|
||||||
|
|
||||||
|
console.log(chalk.green(`Done rebuilding in ${perf.timeSince()}`))
|
||||||
|
|
||||||
toRemove.clear()
|
toRemove.clear()
|
||||||
release()
|
release()
|
||||||
clientRefresh()
|
clientRefresh()
|
||||||
@@ -349,26 +375,22 @@ async function rebuildFromEntrypoint(
|
|||||||
toRemove.add(filePath)
|
toRemove.add(filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildStart = new Date().getTime()
|
const buildId = randomIdNonSecure()
|
||||||
buildData.lastBuildMs = buildStart
|
ctx.buildId = buildId
|
||||||
|
buildData.lastBuildMs = new Date().getTime()
|
||||||
const release = await mut.acquire()
|
const release = await mut.acquire()
|
||||||
|
|
||||||
// there's another build after us, release and let them do it
|
// there's another build after us, release and let them do it
|
||||||
if (buildData.lastBuildMs > buildStart) {
|
if (ctx.buildId !== buildId) {
|
||||||
release()
|
release()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const perf = new PerfTimer()
|
const perf = new PerfTimer()
|
||||||
console.log(chalk.yellow("Detected change, rebuilding..."))
|
console.log(chalk.yellow("Detected change, rebuilding..."))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const filesToRebuild = [...toRebuild].filter((fp) => !toRemove.has(fp))
|
const filesToRebuild = [...toRebuild].filter((fp) => !toRemove.has(fp))
|
||||||
|
|
||||||
const trackedSlugs = [...new Set([...contentMap.keys(), ...toRebuild, ...trackedAssets])]
|
|
||||||
.filter((fp) => !toRemove.has(fp))
|
|
||||||
.map((fp) => slugifyFilePath(path.posix.relative(argv.directory, fp) as FilePath))
|
|
||||||
|
|
||||||
ctx.allSlugs = [...new Set([...initialSlugs, ...trackedSlugs])]
|
|
||||||
const parsedContent = await parseMarkdown(ctx, filesToRebuild)
|
const parsedContent = await parseMarkdown(ctx, filesToRebuild)
|
||||||
for (const content of parsedContent) {
|
for (const content of parsedContent) {
|
||||||
const [_tree, vfile] = content
|
const [_tree, vfile] = content
|
||||||
@@ -382,6 +404,13 @@ async function rebuildFromEntrypoint(
|
|||||||
const parsedFiles = [...contentMap.values()]
|
const parsedFiles = [...contentMap.values()]
|
||||||
const filteredContent = filterContent(ctx, parsedFiles)
|
const filteredContent = filterContent(ctx, parsedFiles)
|
||||||
|
|
||||||
|
// re-update slugs
|
||||||
|
const trackedSlugs = [...new Set([...contentMap.keys(), ...toRebuild, ...trackedAssets])]
|
||||||
|
.filter((fp) => !toRemove.has(fp))
|
||||||
|
.map((fp) => slugifyFilePath(path.posix.relative(argv.directory, fp) as FilePath))
|
||||||
|
|
||||||
|
ctx.allSlugs = [...new Set([...initialSlugs, ...trackedSlugs])]
|
||||||
|
|
||||||
// TODO: we can probably traverse the link graph to figure out what's safe to delete here
|
// TODO: we can probably traverse the link graph to figure out what's safe to delete here
|
||||||
// instead of just deleting everything
|
// instead of just deleting everything
|
||||||
await rimraf(path.join(argv.output, ".*"), { glob: true })
|
await rimraf(path.join(argv.output, ".*"), { glob: true })
|
||||||
@@ -394,10 +423,10 @@ async function rebuildFromEntrypoint(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
release()
|
|
||||||
clientRefresh()
|
clientRefresh()
|
||||||
toRebuild.clear()
|
toRebuild.clear()
|
||||||
toRemove.clear()
|
toRemove.clear()
|
||||||
|
release()
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (argv: Argv, mut: Mutex, clientRefresh: () => void) => {
|
export default async (argv: Argv, mut: Mutex, clientRefresh: () => void) => {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { ValidDateType } from "./components/Date"
|
|||||||
import { QuartzComponent } from "./components/types"
|
import { QuartzComponent } from "./components/types"
|
||||||
import { ValidLocale } from "./i18n"
|
import { ValidLocale } from "./i18n"
|
||||||
import { PluginTypes } from "./plugins/types"
|
import { PluginTypes } from "./plugins/types"
|
||||||
|
import { SocialImageOptions } from "./util/og"
|
||||||
import { Theme } from "./util/theme"
|
import { Theme } from "./util/theme"
|
||||||
|
|
||||||
export type Analytics =
|
export type Analytics =
|
||||||
@@ -19,9 +20,33 @@ export type Analytics =
|
|||||||
websiteId: string
|
websiteId: string
|
||||||
host?: string
|
host?: string
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
provider: "goatcounter"
|
||||||
|
websiteId: string
|
||||||
|
host?: string
|
||||||
|
scriptSrc?: string
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
provider: "posthog"
|
||||||
|
apiKey: string
|
||||||
|
host?: string
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
provider: "tinylytics"
|
||||||
|
siteId: string
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
provider: "cabin"
|
||||||
|
host?: string
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
provider: "clarity"
|
||||||
|
projectId?: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface GlobalConfiguration {
|
export interface GlobalConfiguration {
|
||||||
pageTitle: string
|
pageTitle: string
|
||||||
|
pageTitleSuffix?: string
|
||||||
/** Whether to enable single-page-app style rendering. this prevents flashes of unstyled content and improves smoothness of Quartz */
|
/** Whether to enable single-page-app style rendering. this prevents flashes of unstyled content and improves smoothness of Quartz */
|
||||||
enableSPA: boolean
|
enableSPA: boolean
|
||||||
/** Whether to display Wikipedia-style popovers when hovering over links */
|
/** Whether to display Wikipedia-style popovers when hovering over links */
|
||||||
@@ -40,7 +65,7 @@ export interface GlobalConfiguration {
|
|||||||
/**
|
/**
|
||||||
* Allow to translate the date in the language of your choice.
|
* Allow to translate the date in the language of your choice.
|
||||||
* Also used for UI translation (default: en-US)
|
* Also used for UI translation (default: en-US)
|
||||||
* Need to be formated following BCP 47: https://en.wikipedia.org/wiki/IETF_language_tag
|
* Need to be formatted following BCP 47: https://en.wikipedia.org/wiki/IETF_language_tag
|
||||||
* The first part is the language (en) and the second part is the script/region (US)
|
* The first part is the language (en) and the second part is the script/region (US)
|
||||||
* Language Codes: https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes
|
* Language Codes: https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes
|
||||||
* Region Codes: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
* Region Codes: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
||||||
@@ -58,10 +83,11 @@ export interface FullPageLayout {
|
|||||||
header: QuartzComponent[]
|
header: QuartzComponent[]
|
||||||
beforeBody: QuartzComponent[]
|
beforeBody: QuartzComponent[]
|
||||||
pageBody: QuartzComponent
|
pageBody: QuartzComponent
|
||||||
|
afterBody: QuartzComponent[]
|
||||||
left: QuartzComponent[]
|
left: QuartzComponent[]
|
||||||
right: QuartzComponent[]
|
right: QuartzComponent[]
|
||||||
footer: QuartzComponent
|
footer: QuartzComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PageLayout = Pick<FullPageLayout, "beforeBody" | "left" | "right">
|
export type PageLayout = Pick<FullPageLayout, "beforeBody" | "left" | "right">
|
||||||
export type SharedLayout = Pick<FullPageLayout, "head" | "header" | "footer">
|
export type SharedLayout = Pick<FullPageLayout, "head" | "header" | "footer" | "afterBody">
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { WebSocketServer } from "ws"
|
|||||||
import { randomUUID } from "crypto"
|
import { randomUUID } from "crypto"
|
||||||
import { Mutex } from "async-mutex"
|
import { Mutex } from "async-mutex"
|
||||||
import { CreateArgv } from "./args.js"
|
import { CreateArgv } from "./args.js"
|
||||||
|
import { globby } from "globby"
|
||||||
import {
|
import {
|
||||||
exitIfCancel,
|
exitIfCancel,
|
||||||
escapePath,
|
escapePath,
|
||||||
@@ -32,6 +33,15 @@ import {
|
|||||||
cwd,
|
cwd,
|
||||||
} from "./constants.js"
|
} from "./constants.js"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve content directory path
|
||||||
|
* @param contentPath path to resolve
|
||||||
|
*/
|
||||||
|
function resolveContentPath(contentPath) {
|
||||||
|
if (path.isAbsolute(contentPath)) return path.relative(cwd, contentPath)
|
||||||
|
return path.join(cwd, contentPath)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles `npx quartz create`
|
* Handles `npx quartz create`
|
||||||
* @param {*} argv arguments for `create`
|
* @param {*} argv arguments for `create`
|
||||||
@@ -39,12 +49,12 @@ import {
|
|||||||
export async function handleCreate(argv) {
|
export async function handleCreate(argv) {
|
||||||
console.log()
|
console.log()
|
||||||
intro(chalk.bgGreen.black(` Quartz v${version} `))
|
intro(chalk.bgGreen.black(` Quartz v${version} `))
|
||||||
const contentFolder = path.join(cwd, argv.directory)
|
const contentFolder = resolveContentPath(argv.directory)
|
||||||
let setupStrategy = argv.strategy?.toLowerCase()
|
let setupStrategy = argv.strategy?.toLowerCase()
|
||||||
let linkResolutionStrategy = argv.links?.toLowerCase()
|
let linkResolutionStrategy = argv.links?.toLowerCase()
|
||||||
const sourceDirectory = argv.source
|
const sourceDirectory = argv.source
|
||||||
|
|
||||||
// If all cmd arguments were provided, check if theyre valid
|
// If all cmd arguments were provided, check if they're valid
|
||||||
if (setupStrategy && linkResolutionStrategy) {
|
if (setupStrategy && linkResolutionStrategy) {
|
||||||
// If setup isn't, "new", source argument is required
|
// If setup isn't, "new", source argument is required
|
||||||
if (setupStrategy !== "new") {
|
if (setupStrategy !== "new") {
|
||||||
@@ -236,6 +246,11 @@ export async function handleBuild(argv) {
|
|||||||
type: "css-text",
|
type: "css-text",
|
||||||
cssImports: true,
|
cssImports: true,
|
||||||
}),
|
}),
|
||||||
|
sassPlugin({
|
||||||
|
filter: /\.inline\.scss$/,
|
||||||
|
type: "css",
|
||||||
|
cssImports: true,
|
||||||
|
}),
|
||||||
{
|
{
|
||||||
name: "inline-script-loader",
|
name: "inline-script-loader",
|
||||||
setup(build) {
|
setup(build) {
|
||||||
@@ -285,8 +300,8 @@ export async function handleBuild(argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cleanupBuild) {
|
if (cleanupBuild) {
|
||||||
await cleanupBuild()
|
|
||||||
console.log(chalk.yellow("Detected a source code change, doing a hard rebuild..."))
|
console.log(chalk.yellow("Detected a source code change, doing a hard rebuild..."))
|
||||||
|
await cleanupBuild()
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await ctx.rebuild().catch((err) => {
|
const result = await ctx.rebuild().catch((err) => {
|
||||||
@@ -350,6 +365,15 @@ export async function handleBuild(argv) {
|
|||||||
source: "**/*.*",
|
source: "**/*.*",
|
||||||
headers: [{ key: "Content-Disposition", value: "inline" }],
|
headers: [{ key: "Content-Disposition", value: "inline" }],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
source: "**/*.webp",
|
||||||
|
headers: [{ key: "Content-Type", value: "image/webp" }],
|
||||||
|
},
|
||||||
|
// fixes bug where avif images are displayed as text instead of images (future proof)
|
||||||
|
{
|
||||||
|
source: "**/*.avif",
|
||||||
|
headers: [{ key: "Content-Type", value: "image/avif" }],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
const status = res.statusCode
|
const status = res.statusCode
|
||||||
@@ -418,13 +442,12 @@ export async function handleBuild(argv) {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
console.log("hint: exit with ctrl+c")
|
console.log("hint: exit with ctrl+c")
|
||||||
|
const paths = await globby(["**/*.ts", "**/*.tsx", "**/*.scss", "package.json"])
|
||||||
chokidar
|
chokidar
|
||||||
.watch(["**/*.ts", "**/*.tsx", "**/*.scss", "package.json"], {
|
.watch(paths, { ignoreInitial: true })
|
||||||
ignoreInitial: true,
|
.on("add", () => build(clientRefresh))
|
||||||
})
|
.on("change", () => build(clientRefresh))
|
||||||
.on("all", async () => {
|
.on("unlink", () => build(clientRefresh))
|
||||||
build(clientRefresh)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
await build(() => {})
|
await build(() => {})
|
||||||
ctx.dispose()
|
ctx.dispose()
|
||||||
@@ -436,7 +459,7 @@ export async function handleBuild(argv) {
|
|||||||
* @param {*} argv arguments for `update`
|
* @param {*} argv arguments for `update`
|
||||||
*/
|
*/
|
||||||
export async function handleUpdate(argv) {
|
export async function handleUpdate(argv) {
|
||||||
const contentFolder = path.join(cwd, argv.directory)
|
const contentFolder = resolveContentPath(argv.directory)
|
||||||
console.log(chalk.bgGreen.black(`\n Quartz v${version} \n`))
|
console.log(chalk.bgGreen.black(`\n Quartz v${version} \n`))
|
||||||
console.log("Backing up your content")
|
console.log("Backing up your content")
|
||||||
execSync(
|
execSync(
|
||||||
@@ -457,7 +480,25 @@ export async function handleUpdate(argv) {
|
|||||||
|
|
||||||
await popContentFolder(contentFolder)
|
await popContentFolder(contentFolder)
|
||||||
console.log("Ensuring dependencies are up to date")
|
console.log("Ensuring dependencies are up to date")
|
||||||
const res = spawnSync("npm", ["i"], { stdio: "inherit" })
|
|
||||||
|
/*
|
||||||
|
On Windows, if the command `npm` is really `npm.cmd', this call fails
|
||||||
|
as it will be unable to find `npm`. This is often the case on systems
|
||||||
|
where `npm` is installed via a package manager.
|
||||||
|
|
||||||
|
This means `npx quartz update` will not actually update dependencies
|
||||||
|
on Windows, without a manual `npm i` from the caller.
|
||||||
|
|
||||||
|
However, by spawning a shell, we are able to call `npm.cmd`.
|
||||||
|
See: https://nodejs.org/api/child_process.html#spawning-bat-and-cmd-files-on-windows
|
||||||
|
*/
|
||||||
|
|
||||||
|
const opts = { stdio: "inherit" }
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
opts.shell = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = spawnSync("npm", ["i"], opts)
|
||||||
if (res.status === 0) {
|
if (res.status === 0) {
|
||||||
console.log(chalk.green("Done!"))
|
console.log(chalk.green("Done!"))
|
||||||
} else {
|
} else {
|
||||||
@@ -470,7 +511,7 @@ export async function handleUpdate(argv) {
|
|||||||
* @param {*} argv arguments for `restore`
|
* @param {*} argv arguments for `restore`
|
||||||
*/
|
*/
|
||||||
export async function handleRestore(argv) {
|
export async function handleRestore(argv) {
|
||||||
const contentFolder = path.join(cwd, argv.directory)
|
const contentFolder = resolveContentPath(argv.directory)
|
||||||
await popContentFolder(contentFolder)
|
await popContentFolder(contentFolder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,7 +520,7 @@ export async function handleRestore(argv) {
|
|||||||
* @param {*} argv arguments for `sync`
|
* @param {*} argv arguments for `sync`
|
||||||
*/
|
*/
|
||||||
export async function handleSync(argv) {
|
export async function handleSync(argv) {
|
||||||
const contentFolder = path.join(cwd, argv.directory)
|
const contentFolder = resolveContentPath(argv.directory)
|
||||||
console.log(chalk.bgGreen.black(`\n Quartz v${version} \n`))
|
console.log(chalk.bgGreen.black(`\n Quartz v${version} \n`))
|
||||||
console.log("Backing up your content")
|
console.log("Backing up your content")
|
||||||
|
|
||||||
|
|||||||
@@ -3,34 +3,53 @@ import style from "./styles/backlinks.scss"
|
|||||||
import { resolveRelative, simplifySlug } from "../util/path"
|
import { resolveRelative, simplifySlug } from "../util/path"
|
||||||
import { i18n } from "../i18n"
|
import { i18n } from "../i18n"
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
|
import OverflowListFactory from "./OverflowList"
|
||||||
|
|
||||||
const Backlinks: QuartzComponent = ({
|
interface BacklinksOptions {
|
||||||
fileData,
|
hideWhenEmpty: boolean
|
||||||
allFiles,
|
|
||||||
displayClass,
|
|
||||||
cfg,
|
|
||||||
}: QuartzComponentProps) => {
|
|
||||||
const slug = simplifySlug(fileData.slug!)
|
|
||||||
const backlinkFiles = allFiles.filter((file) => file.links?.includes(slug))
|
|
||||||
return (
|
|
||||||
<div class={classNames(displayClass, "backlinks")}>
|
|
||||||
<h3>{i18n(cfg.locale).components.backlinks.title}</h3>
|
|
||||||
<ul class="overflow">
|
|
||||||
{backlinkFiles.length > 0 ? (
|
|
||||||
backlinkFiles.map((f) => (
|
|
||||||
<li>
|
|
||||||
<a href={resolveRelative(fileData.slug!, f.slug!)} class="internal">
|
|
||||||
{f.frontmatter?.title}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<li>{i18n(cfg.locale).components.backlinks.noBacklinksFound}</li>
|
|
||||||
)}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Backlinks.css = style
|
const defaultOptions: BacklinksOptions = {
|
||||||
export default (() => Backlinks) satisfies QuartzComponentConstructor
|
hideWhenEmpty: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ((opts?: Partial<BacklinksOptions>) => {
|
||||||
|
const options: BacklinksOptions = { ...defaultOptions, ...opts }
|
||||||
|
const { OverflowList, overflowListAfterDOMLoaded } = OverflowListFactory()
|
||||||
|
|
||||||
|
const Backlinks: QuartzComponent = ({
|
||||||
|
fileData,
|
||||||
|
allFiles,
|
||||||
|
displayClass,
|
||||||
|
cfg,
|
||||||
|
}: QuartzComponentProps) => {
|
||||||
|
const slug = simplifySlug(fileData.slug!)
|
||||||
|
const backlinkFiles = allFiles.filter((file) => file.links?.includes(slug))
|
||||||
|
if (options.hideWhenEmpty && backlinkFiles.length == 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div class={classNames(displayClass, "backlinks")}>
|
||||||
|
<h3>{i18n(cfg.locale).components.backlinks.title}</h3>
|
||||||
|
<OverflowList>
|
||||||
|
{backlinkFiles.length > 0 ? (
|
||||||
|
backlinkFiles.map((f) => (
|
||||||
|
<li>
|
||||||
|
<a href={resolveRelative(fileData.slug!, f.slug!)} class="internal">
|
||||||
|
{f.frontmatter?.title}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<li>{i18n(cfg.locale).components.backlinks.noBacklinksFound}</li>
|
||||||
|
)}
|
||||||
|
</OverflowList>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Backlinks.css = style
|
||||||
|
Backlinks.afterDOMLoaded = overflowListAfterDOMLoaded
|
||||||
|
|
||||||
|
return Backlinks
|
||||||
|
}) satisfies QuartzComponentConstructor
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export default ((opts?: Partial<BreadcrumbOptions>) => {
|
|||||||
|
|
||||||
// Add current slug to full path
|
// Add current slug to full path
|
||||||
currentPath = joinSegments(currentPath, slugParts[i])
|
currentPath = joinSegments(currentPath, slugParts[i])
|
||||||
const includeTrailingSlash = !isTagPath || i < 1
|
const includeTrailingSlash = !isTagPath || i < slugParts.length - 1
|
||||||
|
|
||||||
// Format and add current crumb
|
// Format and add current crumb
|
||||||
const crumb = formatCrumb(
|
const crumb = formatCrumb(
|
||||||
|
|||||||
60
quartz/components/Comments.tsx
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
|
import { classNames } from "../util/lang"
|
||||||
|
// @ts-ignore
|
||||||
|
import script from "./scripts/comments.inline"
|
||||||
|
|
||||||
|
type Options = {
|
||||||
|
provider: "giscus"
|
||||||
|
options: {
|
||||||
|
repo: `${string}/${string}`
|
||||||
|
repoId: string
|
||||||
|
category: string
|
||||||
|
categoryId: string
|
||||||
|
themeUrl?: string
|
||||||
|
lightTheme?: string
|
||||||
|
darkTheme?: string
|
||||||
|
mapping?: "url" | "title" | "og:title" | "specific" | "number" | "pathname"
|
||||||
|
strict?: boolean
|
||||||
|
reactionsEnabled?: boolean
|
||||||
|
inputPosition?: "top" | "bottom"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function boolToStringBool(b: boolean): string {
|
||||||
|
return b ? "1" : "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ((opts: Options) => {
|
||||||
|
const Comments: QuartzComponent = ({ displayClass, fileData, cfg }: QuartzComponentProps) => {
|
||||||
|
// check if comments should be displayed according to frontmatter
|
||||||
|
const disableComment: boolean =
|
||||||
|
typeof fileData.frontmatter?.comments !== "undefined" &&
|
||||||
|
(!fileData.frontmatter?.comments || fileData.frontmatter?.comments === "false")
|
||||||
|
if (disableComment) {
|
||||||
|
return <></>
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
class={classNames(displayClass, "giscus")}
|
||||||
|
data-repo={opts.options.repo}
|
||||||
|
data-repo-id={opts.options.repoId}
|
||||||
|
data-category={opts.options.category}
|
||||||
|
data-category-id={opts.options.categoryId}
|
||||||
|
data-mapping={opts.options.mapping ?? "url"}
|
||||||
|
data-strict={boolToStringBool(opts.options.strict ?? true)}
|
||||||
|
data-reactions-enabled={boolToStringBool(opts.options.reactionsEnabled ?? true)}
|
||||||
|
data-input-position={opts.options.inputPosition ?? "bottom"}
|
||||||
|
data-light-theme={opts.options.lightTheme ?? "light"}
|
||||||
|
data-dark-theme={opts.options.darkTheme ?? "dark"}
|
||||||
|
data-theme-url={
|
||||||
|
opts.options.themeUrl ?? `https://${cfg.baseUrl ?? "example.com"}/static/giscus`
|
||||||
|
}
|
||||||
|
></div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Comments.afterDOMLoaded = script
|
||||||
|
|
||||||
|
return Comments
|
||||||
|
}) satisfies QuartzComponentConstructor<Options>
|
||||||
@@ -1,18 +1,22 @@
|
|||||||
import { formatDate, getDate } from "./Date"
|
import { Date, getDate } from "./Date"
|
||||||
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import readingTime from "reading-time"
|
import readingTime from "reading-time"
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
import { i18n } from "../i18n"
|
import { i18n } from "../i18n"
|
||||||
|
import { JSX } from "preact"
|
||||||
|
import style from "./styles/contentMeta.scss"
|
||||||
|
|
||||||
interface ContentMetaOptions {
|
interface ContentMetaOptions {
|
||||||
/**
|
/**
|
||||||
* Whether to display reading time
|
* Whether to display reading time
|
||||||
*/
|
*/
|
||||||
showReadingTime: boolean
|
showReadingTime: boolean
|
||||||
|
showComma: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultOptions: ContentMetaOptions = {
|
const defaultOptions: ContentMetaOptions = {
|
||||||
showReadingTime: true,
|
showReadingTime: true,
|
||||||
|
showComma: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ((opts?: Partial<ContentMetaOptions>) => {
|
export default ((opts?: Partial<ContentMetaOptions>) => {
|
||||||
@@ -23,10 +27,10 @@ export default ((opts?: Partial<ContentMetaOptions>) => {
|
|||||||
const text = fileData.text
|
const text = fileData.text
|
||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
const segments: string[] = []
|
const segments: (string | JSX.Element)[] = []
|
||||||
|
|
||||||
if (fileData.dates) {
|
if (fileData.dates) {
|
||||||
segments.push(formatDate(getDate(cfg, fileData)!, cfg.locale))
|
segments.push(<Date date={getDate(cfg, fileData)!} locale={cfg.locale} />)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display reading time if enabled
|
// Display reading time if enabled
|
||||||
@@ -35,20 +39,20 @@ export default ((opts?: Partial<ContentMetaOptions>) => {
|
|||||||
const displayedTime = i18n(cfg.locale).components.contentMeta.readingTime({
|
const displayedTime = i18n(cfg.locale).components.contentMeta.readingTime({
|
||||||
minutes: Math.ceil(minutes),
|
minutes: Math.ceil(minutes),
|
||||||
})
|
})
|
||||||
segments.push(displayedTime)
|
segments.push(<span>{displayedTime}</span>)
|
||||||
}
|
}
|
||||||
|
|
||||||
return <p class={classNames(displayClass, "content-meta")}>{segments.join(", ")}</p>
|
return (
|
||||||
|
<p show-comma={options.showComma} class={classNames(displayClass, "content-meta")}>
|
||||||
|
{segments}
|
||||||
|
</p>
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentMetadata.css = `
|
ContentMetadata.css = style
|
||||||
.content-meta {
|
|
||||||
margin-top: 0;
|
|
||||||
color: var(--gray);
|
|
||||||
}
|
|
||||||
`
|
|
||||||
return ContentMetadata
|
return ContentMetadata
|
||||||
}) satisfies QuartzComponentConstructor
|
}) satisfies QuartzComponentConstructor
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
// @ts-ignore: this is safe, we don't want to actually make darkmode.inline.ts a module as
|
// @ts-ignore
|
||||||
// modules are automatically deferred and we don't want that to happen for critical beforeDOMLoads
|
|
||||||
// see: https://v8.dev/features/modules#defer
|
|
||||||
import darkmodeScript from "./scripts/darkmode.inline"
|
import darkmodeScript from "./scripts/darkmode.inline"
|
||||||
import styles from "./styles/darkmode.scss"
|
import styles from "./styles/darkmode.scss"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
@@ -9,41 +7,38 @@ import { classNames } from "../util/lang"
|
|||||||
|
|
||||||
const Darkmode: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
|
const Darkmode: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
|
||||||
return (
|
return (
|
||||||
<div class={classNames(displayClass, "darkmode")}>
|
<button class={classNames(displayClass, "darkmode")}>
|
||||||
<input class="toggle" id="darkmode-toggle" type="checkbox" tabIndex={-1} />
|
<svg
|
||||||
<label id="toggle-label-light" for="darkmode-toggle" tabIndex={-1}>
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
<svg
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
version="1.1"
|
||||||
xmlnsXlink="http://www.w3.org/1999/xlink"
|
class="dayIcon"
|
||||||
version="1.1"
|
x="0px"
|
||||||
id="dayIcon"
|
y="0px"
|
||||||
x="0px"
|
viewBox="0 0 35 35"
|
||||||
y="0px"
|
style="enable-background:new 0 0 35 35"
|
||||||
viewBox="0 0 35 35"
|
xmlSpace="preserve"
|
||||||
style="enable-background:new 0 0 35 35"
|
aria-label={i18n(cfg.locale).components.themeToggle.darkMode}
|
||||||
xmlSpace="preserve"
|
>
|
||||||
>
|
<title>{i18n(cfg.locale).components.themeToggle.darkMode}</title>
|
||||||
<title>{i18n(cfg.locale).components.themeToggle.darkMode}</title>
|
<path d="M6,17.5C6,16.672,5.328,16,4.5,16h-3C0.672,16,0,16.672,0,17.5 S0.672,19,1.5,19h3C5.328,19,6,18.328,6,17.5z M7.5,26c-0.414,0-0.789,0.168-1.061,0.439l-2,2C4.168,28.711,4,29.086,4,29.5 C4,30.328,4.671,31,5.5,31c0.414,0,0.789-0.168,1.06-0.44l2-2C8.832,28.289,9,27.914,9,27.5C9,26.672,8.329,26,7.5,26z M17.5,6 C18.329,6,19,5.328,19,4.5v-3C19,0.672,18.329,0,17.5,0S16,0.672,16,1.5v3C16,5.328,16.671,6,17.5,6z M27.5,9 c0.414,0,0.789-0.168,1.06-0.439l2-2C30.832,6.289,31,5.914,31,5.5C31,4.672,30.329,4,29.5,4c-0.414,0-0.789,0.168-1.061,0.44 l-2,2C26.168,6.711,26,7.086,26,7.5C26,8.328,26.671,9,27.5,9z M6.439,8.561C6.711,8.832,7.086,9,7.5,9C8.328,9,9,8.328,9,7.5 c0-0.414-0.168-0.789-0.439-1.061l-2-2C6.289,4.168,5.914,4,5.5,4C4.672,4,4,4.672,4,5.5c0,0.414,0.168,0.789,0.439,1.06 L6.439,8.561z M33.5,16h-3c-0.828,0-1.5,0.672-1.5,1.5s0.672,1.5,1.5,1.5h3c0.828,0,1.5-0.672,1.5-1.5S34.328,16,33.5,16z M28.561,26.439C28.289,26.168,27.914,26,27.5,26c-0.828,0-1.5,0.672-1.5,1.5c0,0.414,0.168,0.789,0.439,1.06l2,2 C28.711,30.832,29.086,31,29.5,31c0.828,0,1.5-0.672,1.5-1.5c0-0.414-0.168-0.789-0.439-1.061L28.561,26.439z M17.5,29 c-0.829,0-1.5,0.672-1.5,1.5v3c0,0.828,0.671,1.5,1.5,1.5s1.5-0.672,1.5-1.5v-3C19,29.672,18.329,29,17.5,29z M17.5,7 C11.71,7,7,11.71,7,17.5S11.71,28,17.5,28S28,23.29,28,17.5S23.29,7,17.5,7z M17.5,25c-4.136,0-7.5-3.364-7.5-7.5 c0-4.136,3.364-7.5,7.5-7.5c4.136,0,7.5,3.364,7.5,7.5C25,21.636,21.636,25,17.5,25z"></path>
|
||||||
<path d="M6,17.5C6,16.672,5.328,16,4.5,16h-3C0.672,16,0,16.672,0,17.5 S0.672,19,1.5,19h3C5.328,19,6,18.328,6,17.5z M7.5,26c-0.414,0-0.789,0.168-1.061,0.439l-2,2C4.168,28.711,4,29.086,4,29.5 C4,30.328,4.671,31,5.5,31c0.414,0,0.789-0.168,1.06-0.44l2-2C8.832,28.289,9,27.914,9,27.5C9,26.672,8.329,26,7.5,26z M17.5,6 C18.329,6,19,5.328,19,4.5v-3C19,0.672,18.329,0,17.5,0S16,0.672,16,1.5v3C16,5.328,16.671,6,17.5,6z M27.5,9 c0.414,0,0.789-0.168,1.06-0.439l2-2C30.832,6.289,31,5.914,31,5.5C31,4.672,30.329,4,29.5,4c-0.414,0-0.789,0.168-1.061,0.44 l-2,2C26.168,6.711,26,7.086,26,7.5C26,8.328,26.671,9,27.5,9z M6.439,8.561C6.711,8.832,7.086,9,7.5,9C8.328,9,9,8.328,9,7.5 c0-0.414-0.168-0.789-0.439-1.061l-2-2C6.289,4.168,5.914,4,5.5,4C4.672,4,4,4.672,4,5.5c0,0.414,0.168,0.789,0.439,1.06 L6.439,8.561z M33.5,16h-3c-0.828,0-1.5,0.672-1.5,1.5s0.672,1.5,1.5,1.5h3c0.828,0,1.5-0.672,1.5-1.5S34.328,16,33.5,16z M28.561,26.439C28.289,26.168,27.914,26,27.5,26c-0.828,0-1.5,0.672-1.5,1.5c0,0.414,0.168,0.789,0.439,1.06l2,2 C28.711,30.832,29.086,31,29.5,31c0.828,0,1.5-0.672,1.5-1.5c0-0.414-0.168-0.789-0.439-1.061L28.561,26.439z M17.5,29 c-0.829,0-1.5,0.672-1.5,1.5v3c0,0.828,0.671,1.5,1.5,1.5s1.5-0.672,1.5-1.5v-3C19,29.672,18.329,29,17.5,29z M17.5,7 C11.71,7,7,11.71,7,17.5S11.71,28,17.5,28S28,23.29,28,17.5S23.29,7,17.5,7z M17.5,25c-4.136,0-7.5-3.364-7.5-7.5 c0-4.136,3.364-7.5,7.5-7.5c4.136,0,7.5,3.364,7.5,7.5C25,21.636,21.636,25,17.5,25z"></path>
|
</svg>
|
||||||
</svg>
|
<svg
|
||||||
</label>
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
<label id="toggle-label-dark" for="darkmode-toggle" tabIndex={-1}>
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
||||||
<svg
|
version="1.1"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
class="nightIcon"
|
||||||
xmlnsXlink="http://www.w3.org/1999/xlink"
|
x="0px"
|
||||||
version="1.1"
|
y="0px"
|
||||||
id="nightIcon"
|
viewBox="0 0 100 100"
|
||||||
x="0px"
|
style="enable-background:new 0 0 100 100"
|
||||||
y="0px"
|
xmlSpace="preserve"
|
||||||
viewBox="0 0 100 100"
|
aria-label={i18n(cfg.locale).components.themeToggle.lightMode}
|
||||||
style="enable-background:new 0 0 100 100"
|
>
|
||||||
xmlSpace="preserve"
|
<title>{i18n(cfg.locale).components.themeToggle.lightMode}</title>
|
||||||
>
|
<path d="M96.76,66.458c-0.853-0.852-2.15-1.064-3.23-0.534c-6.063,2.991-12.858,4.571-19.655,4.571 C62.022,70.495,50.88,65.88,42.5,57.5C29.043,44.043,25.658,23.536,34.076,6.47c0.532-1.08,0.318-2.379-0.534-3.23 c-0.851-0.852-2.15-1.064-3.23-0.534c-4.918,2.427-9.375,5.619-13.246,9.491c-9.447,9.447-14.65,22.008-14.65,35.369 c0,13.36,5.203,25.921,14.65,35.368s22.008,14.65,35.368,14.65c13.361,0,25.921-5.203,35.369-14.65 c3.872-3.871,7.064-8.328,9.491-13.246C97.826,68.608,97.611,67.309,96.76,66.458z"></path>
|
||||||
<title>{i18n(cfg.locale).components.themeToggle.lightMode}</title>
|
</svg>
|
||||||
<path d="M96.76,66.458c-0.853-0.852-2.15-1.064-3.23-0.534c-6.063,2.991-12.858,4.571-19.655,4.571 C62.022,70.495,50.88,65.88,42.5,57.5C29.043,44.043,25.658,23.536,34.076,6.47c0.532-1.08,0.318-2.379-0.534-3.23 c-0.851-0.852-2.15-1.064-3.23-0.534c-4.918,2.427-9.375,5.619-13.246,9.491c-9.447,9.447-14.65,22.008-14.65,35.369 c0,13.36,5.203,25.921,14.65,35.368s22.008,14.65,35.368,14.65c13.361,0,25.921-5.203,35.369-14.65 c3.872-3.871,7.064-8.328,9.491-13.246C97.826,68.608,97.611,67.309,96.76,66.458z"></path>
|
</button>
|
||||||
</svg>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,5 +27,5 @@ export function formatDate(d: Date, locale: ValidLocale = "en-US"): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Date({ date, locale }: Props) {
|
export function Date({ date, locale }: Props) {
|
||||||
return <>{formatDate(date, locale)}</>
|
return <time datetime={date.toISOString()}>{formatDate(date, locale)}</time>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
|
|
||||||
export default ((component?: QuartzComponent) => {
|
export default ((component: QuartzComponent) => {
|
||||||
if (component) {
|
const Component = component
|
||||||
const Component = component
|
const DesktopOnly: QuartzComponent = (props: QuartzComponentProps) => {
|
||||||
const DesktopOnly: QuartzComponent = (props: QuartzComponentProps) => {
|
return <Component displayClass="desktop-only" {...props} />
|
||||||
return <Component displayClass="desktop-only" {...props} />
|
|
||||||
}
|
|
||||||
|
|
||||||
DesktopOnly.displayName = component.displayName
|
|
||||||
DesktopOnly.afterDOMLoaded = component?.afterDOMLoaded
|
|
||||||
DesktopOnly.beforeDOMLoaded = component?.beforeDOMLoaded
|
|
||||||
DesktopOnly.css = component?.css
|
|
||||||
return DesktopOnly
|
|
||||||
} else {
|
|
||||||
return () => <></>
|
|
||||||
}
|
}
|
||||||
}) satisfies QuartzComponentConstructor
|
|
||||||
|
DesktopOnly.displayName = component.displayName
|
||||||
|
DesktopOnly.afterDOMLoaded = component?.afterDOMLoaded
|
||||||
|
DesktopOnly.beforeDOMLoaded = component?.beforeDOMLoaded
|
||||||
|
DesktopOnly.css = component?.css
|
||||||
|
return DesktopOnly
|
||||||
|
}) satisfies QuartzComponentConstructor<QuartzComponent>
|
||||||
|
|||||||
@@ -1,24 +1,37 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import explorerStyle from "./styles/explorer.scss"
|
import style from "./styles/explorer.scss"
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import script from "./scripts/explorer.inline"
|
import script from "./scripts/explorer.inline"
|
||||||
import { ExplorerNode, FileNode, Options } from "./ExplorerNode"
|
|
||||||
import { QuartzPluginData } from "../plugins/vfile"
|
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
import { i18n } from "../i18n"
|
import { i18n } from "../i18n"
|
||||||
|
import { FileTrieNode } from "../util/fileTrie"
|
||||||
|
import OverflowListFactory from "./OverflowList"
|
||||||
|
import { concatenateResources } from "../util/resources"
|
||||||
|
|
||||||
// Options interface defined in `ExplorerNode` to avoid circular dependency
|
type OrderEntries = "sort" | "filter" | "map"
|
||||||
const defaultOptions = {
|
|
||||||
folderClickBehavior: "collapse",
|
export interface Options {
|
||||||
|
title?: string
|
||||||
|
folderDefaultState: "collapsed" | "open"
|
||||||
|
folderClickBehavior: "collapse" | "link"
|
||||||
|
useSavedState: boolean
|
||||||
|
sortFn: (a: FileTrieNode, b: FileTrieNode) => number
|
||||||
|
filterFn: (node: FileTrieNode) => boolean
|
||||||
|
mapFn: (node: FileTrieNode) => void
|
||||||
|
order: OrderEntries[]
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultOptions: Options = {
|
||||||
folderDefaultState: "collapsed",
|
folderDefaultState: "collapsed",
|
||||||
|
folderClickBehavior: "link",
|
||||||
useSavedState: true,
|
useSavedState: true,
|
||||||
mapFn: (node) => {
|
mapFn: (node) => {
|
||||||
return node
|
return node
|
||||||
},
|
},
|
||||||
sortFn: (a, b) => {
|
sortFn: (a, b) => {
|
||||||
// Sort order: folders first, then files. Sort folders and files alphabetically
|
// Sort order: folders first, then files. Sort folders and files alphabeticall
|
||||||
if ((!a.file && !b.file) || (a.file && b.file)) {
|
if ((!a.isFolder && !b.isFolder) || (a.isFolder && b.isFolder)) {
|
||||||
// numeric: true: Whether numeric collation should be used, such that "1" < "2" < "10"
|
// numeric: true: Whether numeric collation should be used, such that "1" < "2" < "10"
|
||||||
// sensitivity: "base": Only strings that differ in base letters compare as unequal. Examples: a ≠ b, a = á, a = A
|
// sensitivity: "base": Only strings that differ in base letters compare as unequal. Examples: a ≠ b, a = á, a = A
|
||||||
return a.displayName.localeCompare(b.displayName, undefined, {
|
return a.displayName.localeCompare(b.displayName, undefined, {
|
||||||
@@ -27,72 +40,67 @@ const defaultOptions = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a.file && !b.file) {
|
if (!a.isFolder && b.isFolder) {
|
||||||
return 1
|
return 1
|
||||||
} else {
|
} else {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
filterFn: (node) => node.name !== "tags",
|
filterFn: (node) => node.slugSegment !== "tags",
|
||||||
order: ["filter", "map", "sort"],
|
order: ["filter", "map", "sort"],
|
||||||
} satisfies Options
|
}
|
||||||
|
|
||||||
|
export type FolderState = {
|
||||||
|
path: string
|
||||||
|
collapsed: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export default ((userOpts?: Partial<Options>) => {
|
export default ((userOpts?: Partial<Options>) => {
|
||||||
// Parse config
|
|
||||||
const opts: Options = { ...defaultOptions, ...userOpts }
|
const opts: Options = { ...defaultOptions, ...userOpts }
|
||||||
|
const { OverflowList, overflowListAfterDOMLoaded } = OverflowListFactory()
|
||||||
|
|
||||||
// memoized
|
const Explorer: QuartzComponent = ({ cfg, displayClass }: QuartzComponentProps) => {
|
||||||
let fileTree: FileNode
|
|
||||||
let jsonTree: string
|
|
||||||
|
|
||||||
function constructFileTree(allFiles: QuartzPluginData[]) {
|
|
||||||
if (fileTree) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Construct tree from allFiles
|
|
||||||
fileTree = new FileNode("")
|
|
||||||
allFiles.forEach((file) => fileTree.add(file))
|
|
||||||
|
|
||||||
// Execute all functions (sort, filter, map) that were provided (if none were provided, only default "sort" is applied)
|
|
||||||
if (opts.order) {
|
|
||||||
// Order is important, use loop with index instead of order.map()
|
|
||||||
for (let i = 0; i < opts.order.length; i++) {
|
|
||||||
const functionName = opts.order[i]
|
|
||||||
if (functionName === "map") {
|
|
||||||
fileTree.map(opts.mapFn)
|
|
||||||
} else if (functionName === "sort") {
|
|
||||||
fileTree.sort(opts.sortFn)
|
|
||||||
} else if (functionName === "filter") {
|
|
||||||
fileTree.filter(opts.filterFn)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get all folders of tree. Initialize with collapsed state
|
|
||||||
// Stringify to pass json tree as data attribute ([data-tree])
|
|
||||||
const folders = fileTree.getFolderPaths(opts.folderDefaultState === "collapsed")
|
|
||||||
jsonTree = JSON.stringify(folders)
|
|
||||||
}
|
|
||||||
|
|
||||||
const Explorer: QuartzComponent = ({
|
|
||||||
cfg,
|
|
||||||
allFiles,
|
|
||||||
displayClass,
|
|
||||||
fileData,
|
|
||||||
}: QuartzComponentProps) => {
|
|
||||||
constructFileTree(allFiles)
|
|
||||||
return (
|
return (
|
||||||
<div class={classNames(displayClass, "explorer")}>
|
<div
|
||||||
|
class={classNames(displayClass, "explorer")}
|
||||||
|
data-behavior={opts.folderClickBehavior}
|
||||||
|
data-collapsed={opts.folderDefaultState}
|
||||||
|
data-savestate={opts.useSavedState}
|
||||||
|
data-data-fns={JSON.stringify({
|
||||||
|
order: opts.order,
|
||||||
|
sortFn: opts.sortFn.toString(),
|
||||||
|
filterFn: opts.filterFn.toString(),
|
||||||
|
mapFn: opts.mapFn.toString(),
|
||||||
|
})}
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
id="explorer"
|
class="explorer-toggle mobile-explorer hide-until-loaded"
|
||||||
data-behavior={opts.folderClickBehavior}
|
data-mobile={true}
|
||||||
data-collapsed={opts.folderDefaultState}
|
aria-controls="explorer-content"
|
||||||
data-savestate={opts.useSavedState}
|
|
||||||
data-tree={jsonTree}
|
|
||||||
>
|
>
|
||||||
<h1>{opts.title ?? i18n(cfg.locale).components.explorer.title}</h1>
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
class="lucide-menu"
|
||||||
|
>
|
||||||
|
<line x1="4" x2="20" y1="12" y2="12" />
|
||||||
|
<line x1="4" x2="20" y1="6" y2="6" />
|
||||||
|
<line x1="4" x2="20" y1="18" y2="18" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="title-button explorer-toggle desktop-explorer"
|
||||||
|
data-mobile={false}
|
||||||
|
aria-expanded={true}
|
||||||
|
>
|
||||||
|
<h2>{opts.title ?? i18n(cfg.locale).components.explorer.title}</h2>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width="14"
|
width="14"
|
||||||
@@ -108,17 +116,47 @@ export default ((userOpts?: Partial<Options>) => {
|
|||||||
<polyline points="6 9 12 15 18 9"></polyline>
|
<polyline points="6 9 12 15 18 9"></polyline>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
<div id="explorer-content">
|
<div class="explorer-content" aria-expanded={false}>
|
||||||
<ul class="overflow" id="explorer-ul">
|
<OverflowList class="explorer-ul" />
|
||||||
<ExplorerNode node={fileTree} opts={opts} fileData={fileData} />
|
|
||||||
<li id="explorer-end" />
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
|
<template id="template-file">
|
||||||
|
<li>
|
||||||
|
<a href="#"></a>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
|
<template id="template-folder">
|
||||||
|
<li>
|
||||||
|
<div class="folder-container">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="12"
|
||||||
|
height="12"
|
||||||
|
viewBox="5 8 14 8"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
class="folder-icon"
|
||||||
|
>
|
||||||
|
<polyline points="6 9 12 15 18 9"></polyline>
|
||||||
|
</svg>
|
||||||
|
<div>
|
||||||
|
<button class="folder-button">
|
||||||
|
<span class="folder-title"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="folder-outer">
|
||||||
|
<ul class="content"></ul>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Explorer.css = explorerStyle
|
Explorer.css = style
|
||||||
Explorer.afterDOMLoaded = script
|
Explorer.afterDOMLoaded = concatenateResources(script, overflowListAfterDOMLoaded)
|
||||||
return Explorer
|
return Explorer
|
||||||
}) satisfies QuartzComponentConstructor
|
}) satisfies QuartzComponentConstructor
|
||||||
|
|||||||
@@ -1,248 +0,0 @@
|
|||||||
// @ts-ignore
|
|
||||||
import { QuartzPluginData } from "../plugins/vfile"
|
|
||||||
import {
|
|
||||||
joinSegments,
|
|
||||||
resolveRelative,
|
|
||||||
clone,
|
|
||||||
simplifySlug,
|
|
||||||
SimpleSlug,
|
|
||||||
FilePath,
|
|
||||||
} from "../util/path"
|
|
||||||
|
|
||||||
type OrderEntries = "sort" | "filter" | "map"
|
|
||||||
|
|
||||||
export interface Options {
|
|
||||||
title?: string
|
|
||||||
folderDefaultState: "collapsed" | "open"
|
|
||||||
folderClickBehavior: "collapse" | "link"
|
|
||||||
useSavedState: boolean
|
|
||||||
sortFn: (a: FileNode, b: FileNode) => number
|
|
||||||
filterFn: (node: FileNode) => boolean
|
|
||||||
mapFn: (node: FileNode) => void
|
|
||||||
order: OrderEntries[]
|
|
||||||
}
|
|
||||||
|
|
||||||
type DataWrapper = {
|
|
||||||
file: QuartzPluginData
|
|
||||||
path: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export type FolderState = {
|
|
||||||
path: string
|
|
||||||
collapsed: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPathSegment(fp: FilePath | undefined, idx: number): string | undefined {
|
|
||||||
if (!fp) {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
return fp.split("/").at(idx)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Structure to add all files into a tree
|
|
||||||
export class FileNode {
|
|
||||||
children: Array<FileNode>
|
|
||||||
name: string // this is the slug segment
|
|
||||||
displayName: string
|
|
||||||
file: QuartzPluginData | null
|
|
||||||
depth: number
|
|
||||||
|
|
||||||
constructor(slugSegment: string, displayName?: string, file?: QuartzPluginData, depth?: number) {
|
|
||||||
this.children = []
|
|
||||||
this.name = slugSegment
|
|
||||||
this.displayName = displayName ?? file?.frontmatter?.title ?? slugSegment
|
|
||||||
this.file = file ? clone(file) : null
|
|
||||||
this.depth = depth ?? 0
|
|
||||||
}
|
|
||||||
|
|
||||||
private insert(fileData: DataWrapper) {
|
|
||||||
if (fileData.path.length === 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const nextSegment = fileData.path[0]
|
|
||||||
|
|
||||||
// base case, insert here
|
|
||||||
if (fileData.path.length === 1) {
|
|
||||||
if (nextSegment === "") {
|
|
||||||
// index case (we are the root and we just found index.md), set our data appropriately
|
|
||||||
const title = fileData.file.frontmatter?.title
|
|
||||||
if (title && title !== "index") {
|
|
||||||
this.displayName = title
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// direct child
|
|
||||||
this.children.push(new FileNode(nextSegment, undefined, fileData.file, this.depth + 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the right child to insert into
|
|
||||||
fileData.path = fileData.path.splice(1)
|
|
||||||
const child = this.children.find((c) => c.name === nextSegment)
|
|
||||||
if (child) {
|
|
||||||
child.insert(fileData)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const newChild = new FileNode(
|
|
||||||
nextSegment,
|
|
||||||
getPathSegment(fileData.file.relativePath, this.depth),
|
|
||||||
undefined,
|
|
||||||
this.depth + 1,
|
|
||||||
)
|
|
||||||
newChild.insert(fileData)
|
|
||||||
this.children.push(newChild)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add new file to tree
|
|
||||||
add(file: QuartzPluginData) {
|
|
||||||
this.insert({ file: file, path: simplifySlug(file.slug!).split("/") })
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter FileNode tree. Behaves similar to `Array.prototype.filter()`, but modifies tree in place
|
|
||||||
* @param filterFn function to filter tree with
|
|
||||||
*/
|
|
||||||
filter(filterFn: (node: FileNode) => boolean) {
|
|
||||||
this.children = this.children.filter(filterFn)
|
|
||||||
this.children.forEach((child) => child.filter(filterFn))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter FileNode tree. Behaves similar to `Array.prototype.map()`, but modifies tree in place
|
|
||||||
* @param mapFn function to use for mapping over tree
|
|
||||||
*/
|
|
||||||
map(mapFn: (node: FileNode) => void) {
|
|
||||||
mapFn(this)
|
|
||||||
this.children.forEach((child) => child.map(mapFn))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get folder representation with state of tree.
|
|
||||||
* Intended to only be called on root node before changes to the tree are made
|
|
||||||
* @param collapsed default state of folders (collapsed by default or not)
|
|
||||||
* @returns array containing folder state for tree
|
|
||||||
*/
|
|
||||||
getFolderPaths(collapsed: boolean): FolderState[] {
|
|
||||||
const folderPaths: FolderState[] = []
|
|
||||||
|
|
||||||
const traverse = (node: FileNode, currentPath: string) => {
|
|
||||||
if (!node.file) {
|
|
||||||
const folderPath = joinSegments(currentPath, node.name)
|
|
||||||
if (folderPath !== "") {
|
|
||||||
folderPaths.push({ path: folderPath, collapsed })
|
|
||||||
}
|
|
||||||
|
|
||||||
node.children.forEach((child) => traverse(child, folderPath))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
traverse(this, "")
|
|
||||||
return folderPaths
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort order: folders first, then files. Sort folders and files alphabetically
|
|
||||||
/**
|
|
||||||
* Sorts tree according to sort/compare function
|
|
||||||
* @param sortFn compare function used for `.sort()`, also used recursively for children
|
|
||||||
*/
|
|
||||||
sort(sortFn: (a: FileNode, b: FileNode) => number) {
|
|
||||||
this.children = this.children.sort(sortFn)
|
|
||||||
this.children.forEach((e) => e.sort(sortFn))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ExplorerNodeProps = {
|
|
||||||
node: FileNode
|
|
||||||
opts: Options
|
|
||||||
fileData: QuartzPluginData
|
|
||||||
fullPath?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ExplorerNode({ node, opts, fullPath, fileData }: ExplorerNodeProps) {
|
|
||||||
// Get options
|
|
||||||
const folderBehavior = opts.folderClickBehavior
|
|
||||||
const isDefaultOpen = opts.folderDefaultState === "open"
|
|
||||||
|
|
||||||
// Calculate current folderPath
|
|
||||||
let folderPath = ""
|
|
||||||
if (node.name !== "") {
|
|
||||||
folderPath = joinSegments(fullPath ?? "", node.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{node.file ? (
|
|
||||||
// Single file node
|
|
||||||
<li key={node.file.slug}>
|
|
||||||
<a href={resolveRelative(fileData.slug!, node.file.slug!)} data-for={node.file.slug}>
|
|
||||||
{node.displayName}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
) : (
|
|
||||||
<li>
|
|
||||||
{node.name !== "" && (
|
|
||||||
// Node with entire folder
|
|
||||||
// Render svg button + folder name, then children
|
|
||||||
<div class="folder-container">
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="12"
|
|
||||||
height="12"
|
|
||||||
viewBox="5 8 14 8"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
stroke-width="2"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
class="folder-icon"
|
|
||||||
>
|
|
||||||
<polyline points="6 9 12 15 18 9"></polyline>
|
|
||||||
</svg>
|
|
||||||
{/* render <a> tag if folderBehavior is "link", otherwise render <button> with collapse click event */}
|
|
||||||
<div key={node.name} data-folderpath={folderPath}>
|
|
||||||
{folderBehavior === "link" ? (
|
|
||||||
<a
|
|
||||||
href={resolveRelative(fileData.slug!, folderPath as SimpleSlug)}
|
|
||||||
data-for={node.name}
|
|
||||||
class="folder-title"
|
|
||||||
>
|
|
||||||
{node.displayName}
|
|
||||||
</a>
|
|
||||||
) : (
|
|
||||||
<button class="folder-button">
|
|
||||||
<span class="folder-title">{node.displayName}</span>
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{/* Recursively render children of folder */}
|
|
||||||
<div class={`folder-outer ${node.depth === 0 || isDefaultOpen ? "open" : ""}`}>
|
|
||||||
<ul
|
|
||||||
// Inline style for left folder paddings
|
|
||||||
style={{
|
|
||||||
paddingLeft: node.name !== "" ? "1.4rem" : "0",
|
|
||||||
}}
|
|
||||||
class="content"
|
|
||||||
data-folderul={folderPath}
|
|
||||||
>
|
|
||||||
{node.children.map((childNode, i) => (
|
|
||||||
<ExplorerNode
|
|
||||||
node={childNode}
|
|
||||||
key={i}
|
|
||||||
opts={opts}
|
|
||||||
fullPath={folderPath}
|
|
||||||
fileData={fileData}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
55
quartz/components/Flex.tsx
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import { concatenateResources } from "../util/resources"
|
||||||
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
|
|
||||||
|
type FlexConfig = {
|
||||||
|
components: {
|
||||||
|
Component: QuartzComponent
|
||||||
|
grow?: boolean
|
||||||
|
shrink?: boolean
|
||||||
|
basis?: string
|
||||||
|
order?: number
|
||||||
|
align?: "start" | "end" | "center" | "stretch"
|
||||||
|
justify?: "start" | "end" | "center" | "between" | "around"
|
||||||
|
}[]
|
||||||
|
direction?: "row" | "row-reverse" | "column" | "column-reverse"
|
||||||
|
wrap?: "nowrap" | "wrap" | "wrap-reverse"
|
||||||
|
gap?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ((config: FlexConfig) => {
|
||||||
|
const Flex: QuartzComponent = (props: QuartzComponentProps) => {
|
||||||
|
const direction = config.direction ?? "row"
|
||||||
|
const wrap = config.wrap ?? "nowrap"
|
||||||
|
const gap = config.gap ?? "1rem"
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={`display: flex; flex-direction: ${direction}; flex-wrap: ${wrap}; gap: ${gap};`}>
|
||||||
|
{config.components.map((c) => {
|
||||||
|
const grow = c.grow ? 1 : 0
|
||||||
|
const shrink = (c.shrink ?? true) ? 1 : 0
|
||||||
|
const basis = c.basis ?? "auto"
|
||||||
|
const order = c.order ?? 0
|
||||||
|
const align = c.align ?? "center"
|
||||||
|
const justify = c.justify ?? "center"
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={`flex-grow: ${grow}; flex-shrink: ${shrink}; flex-basis: ${basis}; order: ${order}; align-self: ${align}; justify-self: ${justify};`}
|
||||||
|
>
|
||||||
|
<c.Component {...props} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Flex.afterDOMLoaded = concatenateResources(
|
||||||
|
...config.components.map((c) => c.Component.afterDOMLoaded),
|
||||||
|
)
|
||||||
|
Flex.beforeDOMLoaded = concatenateResources(
|
||||||
|
...config.components.map((c) => c.Component.beforeDOMLoaded),
|
||||||
|
)
|
||||||
|
Flex.css = concatenateResources(...config.components.map((c) => c.Component.css))
|
||||||
|
return Flex
|
||||||
|
}) satisfies QuartzComponentConstructor<FlexConfig>
|
||||||
@@ -13,7 +13,6 @@ export default ((opts?: Options) => {
|
|||||||
const links = opts?.links ?? []
|
const links = opts?.links ?? []
|
||||||
return (
|
return (
|
||||||
<footer class={`${displayClass ?? ""}`}>
|
<footer class={`${displayClass ?? ""}`}>
|
||||||
<hr />
|
|
||||||
<p>
|
<p>
|
||||||
{i18n(cfg.locale).components.footer.createdWith}{" "}
|
{i18n(cfg.locale).components.footer.createdWith}{" "}
|
||||||
<a href="https://quartz.jzhao.xyz/">Quartz v{version}</a> © {year}
|
<a href="https://quartz.jzhao.xyz/">Quartz v{version}</a> © {year}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ export interface D3Config {
|
|||||||
opacityScale: number
|
opacityScale: number
|
||||||
removeTags: string[]
|
removeTags: string[]
|
||||||
showTags: boolean
|
showTags: boolean
|
||||||
|
focusOnHover?: boolean
|
||||||
|
enableRadial?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GraphOptions {
|
interface GraphOptions {
|
||||||
@@ -37,6 +39,8 @@ const defaultOptions: GraphOptions = {
|
|||||||
opacityScale: 1,
|
opacityScale: 1,
|
||||||
showTags: true,
|
showTags: true,
|
||||||
removeTags: [],
|
removeTags: [],
|
||||||
|
focusOnHover: false,
|
||||||
|
enableRadial: false,
|
||||||
},
|
},
|
||||||
globalGraph: {
|
globalGraph: {
|
||||||
drag: true,
|
drag: true,
|
||||||
@@ -44,16 +48,18 @@ const defaultOptions: GraphOptions = {
|
|||||||
depth: -1,
|
depth: -1,
|
||||||
scale: 0.9,
|
scale: 0.9,
|
||||||
repelForce: 0.5,
|
repelForce: 0.5,
|
||||||
centerForce: 0.3,
|
centerForce: 0.2,
|
||||||
linkDistance: 30,
|
linkDistance: 30,
|
||||||
fontSize: 0.6,
|
fontSize: 0.6,
|
||||||
opacityScale: 1,
|
opacityScale: 1,
|
||||||
showTags: true,
|
showTags: true,
|
||||||
removeTags: [],
|
removeTags: [],
|
||||||
|
focusOnHover: true,
|
||||||
|
enableRadial: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ((opts?: GraphOptions) => {
|
export default ((opts?: Partial<GraphOptions>) => {
|
||||||
const Graph: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
|
const Graph: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
|
||||||
const localGraph = { ...defaultOptions.localGraph, ...opts?.localGraph }
|
const localGraph = { ...defaultOptions.localGraph, ...opts?.localGraph }
|
||||||
const globalGraph = { ...defaultOptions.globalGraph, ...opts?.globalGraph }
|
const globalGraph = { ...defaultOptions.globalGraph, ...opts?.globalGraph }
|
||||||
@@ -61,35 +67,36 @@ export default ((opts?: GraphOptions) => {
|
|||||||
<div class={classNames(displayClass, "graph")}>
|
<div class={classNames(displayClass, "graph")}>
|
||||||
<h3>{i18n(cfg.locale).components.graph.title}</h3>
|
<h3>{i18n(cfg.locale).components.graph.title}</h3>
|
||||||
<div class="graph-outer">
|
<div class="graph-outer">
|
||||||
<div id="graph-container" data-cfg={JSON.stringify(localGraph)}></div>
|
<div class="graph-container" data-cfg={JSON.stringify(localGraph)}></div>
|
||||||
<svg
|
<button class="global-graph-icon" aria-label="Global Graph">
|
||||||
version="1.1"
|
<svg
|
||||||
id="global-graph-icon"
|
version="1.1"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
xmlnsXlink="http://www.w3.org/1999/xlink"
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|
||||||
x="0px"
|
x="0px"
|
||||||
y="0px"
|
y="0px"
|
||||||
viewBox="0 0 55 55"
|
viewBox="0 0 55 55"
|
||||||
fill="currentColor"
|
fill="currentColor"
|
||||||
xmlSpace="preserve"
|
xmlSpace="preserve"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
d="M49,0c-3.309,0-6,2.691-6,6c0,1.035,0.263,2.009,0.726,2.86l-9.829,9.829C32.542,17.634,30.846,17,29,17
|
d="M49,0c-3.309,0-6,2.691-6,6c0,1.035,0.263,2.009,0.726,2.86l-9.829,9.829C32.542,17.634,30.846,17,29,17
|
||||||
s-3.542,0.634-4.898,1.688l-7.669-7.669C16.785,10.424,17,9.74,17,9c0-2.206-1.794-4-4-4S9,6.794,9,9s1.794,4,4,4
|
s-3.542,0.634-4.898,1.688l-7.669-7.669C16.785,10.424,17,9.74,17,9c0-2.206-1.794-4-4-4S9,6.794,9,9s1.794,4,4,4
|
||||||
c0.74,0,1.424-0.215,2.019-0.567l7.669,7.669C21.634,21.458,21,23.154,21,25s0.634,3.542,1.688,4.897L10.024,42.562
|
c0.74,0,1.424-0.215,2.019-0.567l7.669,7.669C21.634,21.458,21,23.154,21,25s0.634,3.542,1.688,4.897L10.024,42.562
|
||||||
C8.958,41.595,7.549,41,6,41c-3.309,0-6,2.691-6,6s2.691,6,6,6s6-2.691,6-6c0-1.035-0.263-2.009-0.726-2.86l12.829-12.829
|
C8.958,41.595,7.549,41,6,41c-3.309,0-6,2.691-6,6s2.691,6,6,6s6-2.691,6-6c0-1.035-0.263-2.009-0.726-2.86l12.829-12.829
|
||||||
c1.106,0.86,2.44,1.436,3.898,1.619v10.16c-2.833,0.478-5,2.942-5,5.91c0,3.309,2.691,6,6,6s6-2.691,6-6c0-2.967-2.167-5.431-5-5.91
|
c1.106,0.86,2.44,1.436,3.898,1.619v10.16c-2.833,0.478-5,2.942-5,5.91c0,3.309,2.691,6,6,6s6-2.691,6-6c0-2.967-2.167-5.431-5-5.91
|
||||||
v-10.16c1.458-0.183,2.792-0.759,3.898-1.619l7.669,7.669C41.215,39.576,41,40.26,41,41c0,2.206,1.794,4,4,4s4-1.794,4-4
|
v-10.16c1.458-0.183,2.792-0.759,3.898-1.619l7.669,7.669C41.215,39.576,41,40.26,41,41c0,2.206,1.794,4,4,4s4-1.794,4-4
|
||||||
s-1.794-4-4-4c-0.74,0-1.424,0.215-2.019,0.567l-7.669-7.669C36.366,28.542,37,26.846,37,25s-0.634-3.542-1.688-4.897l9.665-9.665
|
s-1.794-4-4-4c-0.74,0-1.424,0.215-2.019,0.567l-7.669-7.669C36.366,28.542,37,26.846,37,25s-0.634-3.542-1.688-4.897l9.665-9.665
|
||||||
C46.042,11.405,47.451,12,49,12c3.309,0,6-2.691,6-6S52.309,0,49,0z M11,9c0-1.103,0.897-2,2-2s2,0.897,2,2s-0.897,2-2,2
|
C46.042,11.405,47.451,12,49,12c3.309,0,6-2.691,6-6S52.309,0,49,0z M11,9c0-1.103,0.897-2,2-2s2,0.897,2,2s-0.897,2-2,2
|
||||||
S11,10.103,11,9z M6,51c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S8.206,51,6,51z M33,49c0,2.206-1.794,4-4,4s-4-1.794-4-4
|
S11,10.103,11,9z M6,51c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S8.206,51,6,51z M33,49c0,2.206-1.794,4-4,4s-4-1.794-4-4
|
||||||
s1.794-4,4-4S33,46.794,33,49z M29,31c-3.309,0-6-2.691-6-6s2.691-6,6-6s6,2.691,6,6S32.309,31,29,31z M47,41c0,1.103-0.897,2-2,2
|
s1.794-4,4-4S33,46.794,33,49z M29,31c-3.309,0-6-2.691-6-6s2.691-6,6-6s6,2.691,6,6S32.309,31,29,31z M47,41c0,1.103-0.897,2-2,2
|
||||||
s-2-0.897-2-2s0.897-2,2-2S47,39.897,47,41z M49,10c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S51.206,10,49,10z"
|
s-2-0.897-2-2s0.897-2,2-2S47,39.897,47,41z M49,10c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S51.206,10,49,10z"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="global-graph-outer">
|
<div class="global-graph-outer">
|
||||||
<div id="global-graph-container" data-cfg={JSON.stringify(globalGraph)}></div>
|
<div class="global-graph-container" data-cfg={JSON.stringify(globalGraph)}></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,47 +1,99 @@
|
|||||||
import { i18n } from "../i18n"
|
import { i18n } from "../i18n"
|
||||||
import { FullSlug, joinSegments, pathToRoot } from "../util/path"
|
import { FullSlug, getFileExtension, joinSegments, pathToRoot } from "../util/path"
|
||||||
import { JSResourceToScriptElement } from "../util/resources"
|
import { CSSResourceToStyleElement, JSResourceToScriptElement } from "../util/resources"
|
||||||
|
import { googleFontHref } from "../util/theme"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
|
import { unescapeHTML } from "../util/escape"
|
||||||
|
import { CustomOgImagesEmitterName } from "../plugins/emitters/ogImage"
|
||||||
export default (() => {
|
export default (() => {
|
||||||
const Head: QuartzComponent = ({ cfg, fileData, externalResources }: QuartzComponentProps) => {
|
const Head: QuartzComponent = ({
|
||||||
const title = fileData.frontmatter?.title ?? i18n(cfg.locale).propertyDefaults.title
|
cfg,
|
||||||
|
fileData,
|
||||||
|
externalResources,
|
||||||
|
ctx,
|
||||||
|
}: QuartzComponentProps) => {
|
||||||
|
const titleSuffix = cfg.pageTitleSuffix ?? ""
|
||||||
|
const title =
|
||||||
|
(fileData.frontmatter?.title ?? i18n(cfg.locale).propertyDefaults.title) + titleSuffix
|
||||||
const description =
|
const description =
|
||||||
fileData.description?.trim() ?? i18n(cfg.locale).propertyDefaults.description
|
fileData.frontmatter?.socialDescription ??
|
||||||
const { css, js } = externalResources
|
fileData.frontmatter?.description ??
|
||||||
|
unescapeHTML(fileData.description?.trim() ?? i18n(cfg.locale).propertyDefaults.description)
|
||||||
|
|
||||||
|
const { css, js, additionalHead } = externalResources
|
||||||
|
|
||||||
const url = new URL(`https://${cfg.baseUrl ?? "example.com"}`)
|
const url = new URL(`https://${cfg.baseUrl ?? "example.com"}`)
|
||||||
const path = url.pathname as FullSlug
|
const path = url.pathname as FullSlug
|
||||||
const baseDir = fileData.slug === "404" ? path : pathToRoot(fileData.slug!)
|
const baseDir = fileData.slug === "404" ? path : pathToRoot(fileData.slug!)
|
||||||
|
|
||||||
const iconPath = joinSegments(baseDir, "static/icon.png")
|
const iconPath = joinSegments(baseDir, "static/icon.png")
|
||||||
const ogImagePath = `https://${cfg.baseUrl}/static/og-image.png`
|
|
||||||
|
// Url of current page
|
||||||
|
const socialUrl =
|
||||||
|
fileData.slug === "404" ? url.toString() : joinSegments(url.toString(), fileData.slug!)
|
||||||
|
|
||||||
|
const usesCustomOgImage = ctx.cfg.plugins.emitters.some(
|
||||||
|
(e) => e.name === CustomOgImagesEmitterName,
|
||||||
|
)
|
||||||
|
const ogImageDefaultPath = `https://${cfg.baseUrl}/static/og-image.png`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<head>
|
<head>
|
||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
<meta charSet="utf-8" />
|
<meta charSet="utf-8" />
|
||||||
{cfg.theme.cdnCaching && (
|
{cfg.theme.cdnCaching && cfg.theme.fontOrigin === "googleFonts" && (
|
||||||
<>
|
<>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||||
|
<link rel="stylesheet" href={googleFontHref(cfg.theme)} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossOrigin="anonymous" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
||||||
|
<meta name="og:site_name" content={cfg.pageTitle}></meta>
|
||||||
<meta property="og:title" content={title} />
|
<meta property="og:title" content={title} />
|
||||||
|
<meta property="og:type" content="website" />
|
||||||
|
<meta name="twitter:card" content="summary_large_image" />
|
||||||
|
<meta name="twitter:title" content={title} />
|
||||||
|
<meta name="twitter:description" content={description} />
|
||||||
<meta property="og:description" content={description} />
|
<meta property="og:description" content={description} />
|
||||||
{cfg.baseUrl && <meta property="og:image" content={ogImagePath} />}
|
<meta property="og:image:alt" content={description} />
|
||||||
<meta property="og:width" content="1200" />
|
|
||||||
<meta property="og:height" content="675" />
|
{!usesCustomOgImage && (
|
||||||
|
<>
|
||||||
|
<meta property="og:image" content={ogImageDefaultPath} />
|
||||||
|
<meta property="og:image:url" content={ogImageDefaultPath} />
|
||||||
|
<meta name="twitter:image" content={ogImageDefaultPath} />
|
||||||
|
<meta
|
||||||
|
property="og:image:type"
|
||||||
|
content={`image/${getFileExtension(ogImageDefaultPath) ?? "png"}`}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{cfg.baseUrl && (
|
||||||
|
<>
|
||||||
|
<meta property="twitter:domain" content={cfg.baseUrl}></meta>
|
||||||
|
<meta property="og:url" content={socialUrl}></meta>
|
||||||
|
<meta property="twitter:url" content={socialUrl}></meta>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
<link rel="icon" href={iconPath} />
|
<link rel="icon" href={iconPath} />
|
||||||
<meta name="description" content={description} />
|
<meta name="description" content={description} />
|
||||||
<meta name="generator" content="Quartz" />
|
<meta name="generator" content="Quartz" />
|
||||||
{css.map((href) => (
|
|
||||||
<link key={href} href={href} rel="stylesheet" type="text/css" spa-preserve />
|
{css.map((resource) => CSSResourceToStyleElement(resource, true))}
|
||||||
))}
|
|
||||||
{js
|
{js
|
||||||
.filter((resource) => resource.loadTime === "beforeDOMReady")
|
.filter((resource) => resource.loadTime === "beforeDOMReady")
|
||||||
.map((res) => JSResourceToScriptElement(res, true))}
|
.map((res) => JSResourceToScriptElement(res, true))}
|
||||||
|
{additionalHead.map((resource) => {
|
||||||
|
if (typeof resource === "function") {
|
||||||
|
return resource(fileData)
|
||||||
|
} else {
|
||||||
|
return resource
|
||||||
|
}
|
||||||
|
})}
|
||||||
</head>
|
</head>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
|
|
||||||
export default ((component?: QuartzComponent) => {
|
export default ((component: QuartzComponent) => {
|
||||||
if (component) {
|
const Component = component
|
||||||
const Component = component
|
const MobileOnly: QuartzComponent = (props: QuartzComponentProps) => {
|
||||||
const MobileOnly: QuartzComponent = (props: QuartzComponentProps) => {
|
return <Component displayClass="mobile-only" {...props} />
|
||||||
return <Component displayClass="mobile-only" {...props} />
|
|
||||||
}
|
|
||||||
|
|
||||||
MobileOnly.displayName = component.displayName
|
|
||||||
MobileOnly.afterDOMLoaded = component?.afterDOMLoaded
|
|
||||||
MobileOnly.beforeDOMLoaded = component?.beforeDOMLoaded
|
|
||||||
MobileOnly.css = component?.css
|
|
||||||
return MobileOnly
|
|
||||||
} else {
|
|
||||||
return () => <></>
|
|
||||||
}
|
}
|
||||||
}) satisfies QuartzComponentConstructor
|
|
||||||
|
MobileOnly.displayName = component.displayName
|
||||||
|
MobileOnly.afterDOMLoaded = component?.afterDOMLoaded
|
||||||
|
MobileOnly.beforeDOMLoaded = component?.beforeDOMLoaded
|
||||||
|
MobileOnly.css = component?.css
|
||||||
|
return MobileOnly
|
||||||
|
}) satisfies QuartzComponentConstructor<QuartzComponent>
|
||||||
|
|||||||
48
quartz/components/OverflowList.tsx
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { JSX } from "preact"
|
||||||
|
import { randomIdNonSecure } from "../util/random"
|
||||||
|
|
||||||
|
const OverflowList = ({
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: JSX.HTMLAttributes<HTMLUListElement> & { id: string }) => {
|
||||||
|
return (
|
||||||
|
<ul {...props} class={[props.class, "overflow"].filter(Boolean).join(" ")} id={props.id}>
|
||||||
|
{children}
|
||||||
|
<li class="overflow-end" />
|
||||||
|
</ul>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default () => {
|
||||||
|
const id = randomIdNonSecure()
|
||||||
|
|
||||||
|
return {
|
||||||
|
OverflowList: (props: JSX.HTMLAttributes<HTMLUListElement>) => (
|
||||||
|
<OverflowList {...props} id={id} />
|
||||||
|
),
|
||||||
|
overflowListAfterDOMLoaded: `
|
||||||
|
document.addEventListener("nav", (e) => {
|
||||||
|
const observer = new IntersectionObserver((entries) => {
|
||||||
|
for (const entry of entries) {
|
||||||
|
const parentUl = entry.target.parentElement
|
||||||
|
if (!parentUl) return
|
||||||
|
if (entry.isIntersecting) {
|
||||||
|
parentUl.classList.remove("gradient-active")
|
||||||
|
} else {
|
||||||
|
parentUl.classList.add("gradient-active")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const ul = document.getElementById("${id}")
|
||||||
|
if (!ul) return
|
||||||
|
|
||||||
|
const end = ul.querySelector(".overflow-end")
|
||||||
|
if (!end) return
|
||||||
|
|
||||||
|
observer.observe(end)
|
||||||
|
window.addCleanup(() => observer.disconnect())
|
||||||
|
})
|
||||||
|
`,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,9 +4,9 @@ import { Date, getDate } from "./Date"
|
|||||||
import { QuartzComponent, QuartzComponentProps } from "./types"
|
import { QuartzComponent, QuartzComponentProps } from "./types"
|
||||||
import { GlobalConfiguration } from "../cfg"
|
import { GlobalConfiguration } from "../cfg"
|
||||||
|
|
||||||
export function byDateAndAlphabetical(
|
export type SortFn = (f1: QuartzPluginData, f2: QuartzPluginData) => number
|
||||||
cfg: GlobalConfiguration,
|
|
||||||
): (f1: QuartzPluginData, f2: QuartzPluginData) => number {
|
export function byDateAndAlphabetical(cfg: GlobalConfiguration): SortFn {
|
||||||
return (f1, f2) => {
|
return (f1, f2) => {
|
||||||
if (f1.dates && f2.dates) {
|
if (f1.dates && f2.dates) {
|
||||||
// sort descending
|
// sort descending
|
||||||
@@ -27,10 +27,12 @@ export function byDateAndAlphabetical(
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
limit?: number
|
limit?: number
|
||||||
|
sort?: SortFn
|
||||||
} & QuartzComponentProps
|
} & QuartzComponentProps
|
||||||
|
|
||||||
export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit }: Props) => {
|
export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit, sort }: Props) => {
|
||||||
let list = allFiles.sort(byDateAndAlphabetical(cfg))
|
const sorter = sort ?? byDateAndAlphabetical(cfg)
|
||||||
|
let list = allFiles.sort(sorter)
|
||||||
if (limit) {
|
if (limit) {
|
||||||
list = list.slice(0, limit)
|
list = list.slice(0, limit)
|
||||||
}
|
}
|
||||||
@@ -44,11 +46,9 @@ export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit }: Pr
|
|||||||
return (
|
return (
|
||||||
<li class="section-li">
|
<li class="section-li">
|
||||||
<div class="section">
|
<div class="section">
|
||||||
{page.dates && (
|
<p class="meta">
|
||||||
<p class="meta">
|
{page.dates && <Date date={getDate(cfg, page)!} locale={cfg.locale} />}
|
||||||
<Date date={getDate(cfg, page)!} locale={cfg.locale} />
|
</p>
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
<div class="desc">
|
<div class="desc">
|
||||||
<h3>
|
<h3>
|
||||||
<a href={resolveRelative(fileData.slug!, page.slug!)} class="internal">
|
<a href={resolveRelative(fileData.slug!, page.slug!)} class="internal">
|
||||||
@@ -63,7 +63,7 @@ export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit }: Pr
|
|||||||
class="internal tag-link"
|
class="internal tag-link"
|
||||||
href={resolveRelative(fileData.slug!, `tags/${tag}` as FullSlug)}
|
href={resolveRelative(fileData.slug!, `tags/${tag}` as FullSlug)}
|
||||||
>
|
>
|
||||||
#{tag}
|
{tag}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -7,14 +7,15 @@ const PageTitle: QuartzComponent = ({ fileData, cfg, displayClass }: QuartzCompo
|
|||||||
const title = cfg?.pageTitle ?? i18n(cfg.locale).propertyDefaults.title
|
const title = cfg?.pageTitle ?? i18n(cfg.locale).propertyDefaults.title
|
||||||
const baseDir = pathToRoot(fileData.slug!)
|
const baseDir = pathToRoot(fileData.slug!)
|
||||||
return (
|
return (
|
||||||
<h1 class={classNames(displayClass, "page-title")}>
|
<h2 class={classNames(displayClass, "page-title")}>
|
||||||
<a href={baseDir}>{title}</a>
|
<a href={baseDir}>{title}</a>
|
||||||
</h1>
|
</h2>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
PageTitle.css = `
|
PageTitle.css = `
|
||||||
.page-title {
|
.page-title {
|
||||||
|
font-size: 1.75rem;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ interface Options {
|
|||||||
title?: string
|
title?: string
|
||||||
limit: number
|
limit: number
|
||||||
linkToMore: SimpleSlug | false
|
linkToMore: SimpleSlug | false
|
||||||
|
showTags: boolean
|
||||||
filter: (f: QuartzPluginData) => boolean
|
filter: (f: QuartzPluginData) => boolean
|
||||||
sort: (f1: QuartzPluginData, f2: QuartzPluginData) => number
|
sort: (f1: QuartzPluginData, f2: QuartzPluginData) => number
|
||||||
}
|
}
|
||||||
@@ -19,6 +20,7 @@ interface Options {
|
|||||||
const defaultOptions = (cfg: GlobalConfiguration): Options => ({
|
const defaultOptions = (cfg: GlobalConfiguration): Options => ({
|
||||||
limit: 3,
|
limit: 3,
|
||||||
linkToMore: false,
|
linkToMore: false,
|
||||||
|
showTags: true,
|
||||||
filter: () => true,
|
filter: () => true,
|
||||||
sort: byDateAndAlphabetical(cfg),
|
sort: byDateAndAlphabetical(cfg),
|
||||||
})
|
})
|
||||||
@@ -56,18 +58,20 @@ export default ((userOpts?: Partial<Options>) => {
|
|||||||
<Date date={getDate(cfg, page)!} locale={cfg.locale} />
|
<Date date={getDate(cfg, page)!} locale={cfg.locale} />
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
<ul class="tags">
|
{opts.showTags && (
|
||||||
{tags.map((tag) => (
|
<ul class="tags">
|
||||||
<li>
|
{tags.map((tag) => (
|
||||||
<a
|
<li>
|
||||||
class="internal tag-link"
|
<a
|
||||||
href={resolveRelative(fileData.slug!, `tags/${tag}` as FullSlug)}
|
class="internal tag-link"
|
||||||
>
|
href={resolveRelative(fileData.slug!, `tags/${tag}` as FullSlug)}
|
||||||
#{tag}
|
>
|
||||||
</a>
|
{tag}
|
||||||
</li>
|
</a>
|
||||||
))}
|
</li>
|
||||||
</ul>
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -19,35 +19,27 @@ export default ((userOpts?: Partial<SearchOptions>) => {
|
|||||||
const searchPlaceholder = i18n(cfg.locale).components.search.searchBarPlaceholder
|
const searchPlaceholder = i18n(cfg.locale).components.search.searchBarPlaceholder
|
||||||
return (
|
return (
|
||||||
<div class={classNames(displayClass, "search")}>
|
<div class={classNames(displayClass, "search")}>
|
||||||
<div id="search-icon">
|
<button class="search-button">
|
||||||
<p>{i18n(cfg.locale).components.search.title}</p>
|
<p>{i18n(cfg.locale).components.search.title}</p>
|
||||||
<div></div>
|
<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 19.9 19.7">
|
||||||
<svg
|
<title>Search</title>
|
||||||
tabIndex={0}
|
|
||||||
aria-labelledby="title desc"
|
|
||||||
role="img"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
viewBox="0 0 19.9 19.7"
|
|
||||||
>
|
|
||||||
<title id="title">Search</title>
|
|
||||||
<desc id="desc">Search</desc>
|
|
||||||
<g class="search-path" fill="none">
|
<g class="search-path" fill="none">
|
||||||
<path stroke-linecap="square" d="M18.5 18.3l-5.4-5.4" />
|
<path stroke-linecap="square" d="M18.5 18.3l-5.4-5.4" />
|
||||||
<circle cx="8" cy="8" r="7" />
|
<circle cx="8" cy="8" r="7" />
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</button>
|
||||||
<div id="search-container">
|
<div class="search-container">
|
||||||
<div id="search-space">
|
<div class="search-space">
|
||||||
<input
|
<input
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
id="search-bar"
|
class="search-bar"
|
||||||
name="search"
|
name="search"
|
||||||
type="text"
|
type="text"
|
||||||
aria-label={searchPlaceholder}
|
aria-label={searchPlaceholder}
|
||||||
placeholder={searchPlaceholder}
|
placeholder={searchPlaceholder}
|
||||||
/>
|
/>
|
||||||
<div id="search-layout" data-preview={opts.enablePreview}></div>
|
<div class="search-layout" data-preview={opts.enablePreview}></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import { classNames } from "../util/lang"
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import script from "./scripts/toc.inline"
|
import script from "./scripts/toc.inline"
|
||||||
import { i18n } from "../i18n"
|
import { i18n } from "../i18n"
|
||||||
|
import OverflowListFactory from "./OverflowList"
|
||||||
|
import { concatenateResources } from "../util/resources"
|
||||||
|
|
||||||
interface Options {
|
interface Options {
|
||||||
layout: "modern" | "legacy"
|
layout: "modern" | "legacy"
|
||||||
@@ -15,36 +17,70 @@ const defaultOptions: Options = {
|
|||||||
layout: "modern",
|
layout: "modern",
|
||||||
}
|
}
|
||||||
|
|
||||||
const TableOfContents: QuartzComponent = ({
|
export default ((opts?: Partial<Options>) => {
|
||||||
fileData,
|
const layout = opts?.layout ?? defaultOptions.layout
|
||||||
displayClass,
|
const { OverflowList, overflowListAfterDOMLoaded } = OverflowListFactory()
|
||||||
cfg,
|
const TableOfContents: QuartzComponent = ({
|
||||||
}: QuartzComponentProps) => {
|
fileData,
|
||||||
if (!fileData.toc) {
|
displayClass,
|
||||||
return null
|
cfg,
|
||||||
|
}: QuartzComponentProps) => {
|
||||||
|
if (!fileData.toc) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class={classNames(displayClass, "toc")}>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class={fileData.collapseToc ? "collapsed toc-header" : "toc-header"}
|
||||||
|
aria-controls="toc-content"
|
||||||
|
aria-expanded={!fileData.collapseToc}
|
||||||
|
>
|
||||||
|
<h3>{i18n(cfg.locale).components.tableOfContents.title}</h3>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
class="fold"
|
||||||
|
>
|
||||||
|
<polyline points="6 9 12 15 18 9"></polyline>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<div class={fileData.collapseToc ? "collapsed toc-content" : "toc-content"}>
|
||||||
|
<OverflowList>
|
||||||
|
{fileData.toc.map((tocEntry) => (
|
||||||
|
<li key={tocEntry.slug} class={`depth-${tocEntry.depth}`}>
|
||||||
|
<a href={`#${tocEntry.slug}`} data-for={tocEntry.slug}>
|
||||||
|
{tocEntry.text}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</OverflowList>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
TableOfContents.css = modernStyle
|
||||||
<div class={classNames(displayClass, "toc")}>
|
TableOfContents.afterDOMLoaded = concatenateResources(script, overflowListAfterDOMLoaded)
|
||||||
<button type="button" id="toc" class={fileData.collapseToc ? "collapsed" : ""}>
|
|
||||||
<h3>{i18n(cfg.locale).components.tableOfContents.title}</h3>
|
const LegacyTableOfContents: QuartzComponent = ({ fileData, cfg }: QuartzComponentProps) => {
|
||||||
<svg
|
if (!fileData.toc) {
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
return null
|
||||||
width="24"
|
}
|
||||||
height="24"
|
return (
|
||||||
viewBox="0 0 24 24"
|
<details class="toc" open={!fileData.collapseToc}>
|
||||||
fill="none"
|
<summary>
|
||||||
stroke="currentColor"
|
<h3>{i18n(cfg.locale).components.tableOfContents.title}</h3>
|
||||||
stroke-width="2"
|
</summary>
|
||||||
stroke-linecap="round"
|
<ul>
|
||||||
stroke-linejoin="round"
|
|
||||||
class="fold"
|
|
||||||
>
|
|
||||||
<polyline points="6 9 12 15 18 9"></polyline>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
<div id="toc-content">
|
|
||||||
<ul class="overflow">
|
|
||||||
{fileData.toc.map((tocEntry) => (
|
{fileData.toc.map((tocEntry) => (
|
||||||
<li key={tocEntry.slug} class={`depth-${tocEntry.depth}`}>
|
<li key={tocEntry.slug} class={`depth-${tocEntry.depth}`}>
|
||||||
<a href={`#${tocEntry.slug}`} data-for={tocEntry.slug}>
|
<a href={`#${tocEntry.slug}`} data-for={tocEntry.slug}>
|
||||||
@@ -53,37 +89,10 @@ const TableOfContents: QuartzComponent = ({
|
|||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</details>
|
||||||
</div>
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
TableOfContents.css = modernStyle
|
|
||||||
TableOfContents.afterDOMLoaded = script
|
|
||||||
|
|
||||||
const LegacyTableOfContents: QuartzComponent = ({ fileData, cfg }: QuartzComponentProps) => {
|
|
||||||
if (!fileData.toc) {
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
return (
|
LegacyTableOfContents.css = legacyStyle
|
||||||
<details id="toc" open={!fileData.collapseToc}>
|
|
||||||
<summary>
|
|
||||||
<h3>{i18n(cfg.locale).components.tableOfContents.title}</h3>
|
|
||||||
</summary>
|
|
||||||
<ul>
|
|
||||||
{fileData.toc.map((tocEntry) => (
|
|
||||||
<li key={tocEntry.slug} class={`depth-${tocEntry.depth}`}>
|
|
||||||
<a href={`#${tocEntry.slug}`} data-for={tocEntry.slug}>
|
|
||||||
{tocEntry.text}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</details>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
LegacyTableOfContents.css = legacyStyle
|
|
||||||
|
|
||||||
export default ((opts?: Partial<Options>) => {
|
|
||||||
const layout = opts?.layout ?? defaultOptions.layout
|
|
||||||
return layout === "modern" ? TableOfContents : LegacyTableOfContents
|
return layout === "modern" ? TableOfContents : LegacyTableOfContents
|
||||||
}) satisfies QuartzComponentConstructor
|
}) satisfies QuartzComponentConstructor
|
||||||
|
|||||||
@@ -9,12 +9,11 @@ const TagList: QuartzComponent = ({ fileData, displayClass }: QuartzComponentPro
|
|||||||
return (
|
return (
|
||||||
<ul class={classNames(displayClass, "tags")}>
|
<ul class={classNames(displayClass, "tags")}>
|
||||||
{tags.map((tag) => {
|
{tags.map((tag) => {
|
||||||
const display = `#${tag}`
|
|
||||||
const linkDest = baseDir + `/tags/${slugTag(tag)}`
|
const linkDest = baseDir + `/tags/${slugTag(tag)}`
|
||||||
return (
|
return (
|
||||||
<li>
|
<li>
|
||||||
<a href={linkDest} class="internal tag-link">
|
<a href={linkDest} class="internal tag-link">
|
||||||
{display}
|
{tag}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
@@ -34,7 +33,6 @@ TagList.css = `
|
|||||||
gap: 0.4rem;
|
gap: 0.4rem;
|
||||||
margin: 1rem 0;
|
margin: 1rem 0;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-self: end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.section-li > .section > .tags {
|
.section-li > .section > .tags {
|
||||||
|
|||||||