From 6fb8a3368949d33f8f4f0da4eb4486c17cd2bdd9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Heredero?=
<63239207+Klagarge@users.noreply.github.com>
Date: Sun, 10 Apr 2022 00:14:01 +0200
Subject: [PATCH] Initial commit
---
.github/FUNDING.yml | 1 +
.github/ISSUE_TEMPLATE/bug_report.md | 32 ++
.github/ISSUE_TEMPLATE/feature_request.md | 20 +
.github/workflows/deploy.yaml | 37 ++
.gitignore | 7 +
.hugo_build.lock | 0
CODE_OF_CONDUCT.md | 93 ++++
LICENSE.txt | 21 +
Makefile | 18 +
README.md | 17 +
assets/indices/.gitkeep | 0
assets/js/darkmode.js | 29 +
assets/js/graph.js | 220 ++++++++
assets/js/popover.js | 35 ++
assets/js/search.js | 239 ++++++++
assets/styles/base.scss | 571 ++++++++++++++++++++
assets/styles/custom.scss | 24 +
assets/styles/darkmode.scss | 44 ++
assets/styles/syntax.scss | 99 ++++
config.toml | 30 +
content/_index.md | 27 +
content/notes/CJK + Latex Support (测试).md | 40 ++
content/notes/config.md | 67 +++
content/notes/custom Domain.md | 17 +
content/notes/editing.md | 69 +++
content/notes/hosting.md | 84 +++
content/notes/ignore notes.md | 31 ++
content/notes/images/github-actions.png | Bin 0 -> 118756 bytes
content/notes/images/github-pages.png | Bin 0 -> 231282 bytes
content/notes/images/google-domains.png | Bin 0 -> 73570 bytes
content/notes/images/obsidian-settings.png | Bin 0 -> 26089 bytes
content/notes/obsidian.md | 29 +
content/notes/philosophy.md | 17 +
content/notes/preview changes.md | 38 ++
content/notes/setup.md | 58 ++
content/notes/showcase.md | 17 +
content/notes/troubleshooting.md | 81 +++
content/private/private-note.md | 5 +
content/templates/post.md | 3 +
data/config.yaml | 15 +
data/graphConfig.yaml | 6 +
layouts/404.html | 16 +
layouts/_default/_markup/render-image.html | 8 +
layouts/_default/_markup/render-link.html | 16 +
layouts/_default/baseof.html | 10 +
layouts/_default/section.html | 25 +
layouts/_default/single.html | 33 ++
layouts/_default/taxonomy.html | 34 ++
layouts/_default/term.html | 25 +
layouts/index.html | 24 +
layouts/partials/backlinks.html | 24 +
layouts/partials/contact.html | 14 +
layouts/partials/darkmode.html | 15 +
layouts/partials/footer.html | 11 +
layouts/partials/graph.html | 25 +
layouts/partials/head.html | 46 ++
layouts/partials/katex.html | 16 +
layouts/partials/page-list.html | 15 +
layouts/partials/popover.html | 7 +
layouts/partials/search.html | 10 +
layouts/partials/textprocessing.html | 56 ++
layouts/partials/toc.html | 8 +
screenshot.png | Bin 0 -> 1104069 bytes
static/icon.png | Bin 0 -> 17368 bytes
64 files changed, 2579 insertions(+)
create mode 100644 .github/FUNDING.yml
create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md
create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md
create mode 100644 .github/workflows/deploy.yaml
create mode 100644 .gitignore
create mode 100644 .hugo_build.lock
create mode 100644 CODE_OF_CONDUCT.md
create mode 100644 LICENSE.txt
create mode 100644 Makefile
create mode 100644 README.md
create mode 100644 assets/indices/.gitkeep
create mode 100644 assets/js/darkmode.js
create mode 100644 assets/js/graph.js
create mode 100644 assets/js/popover.js
create mode 100644 assets/js/search.js
create mode 100644 assets/styles/base.scss
create mode 100644 assets/styles/custom.scss
create mode 100644 assets/styles/darkmode.scss
create mode 100644 assets/styles/syntax.scss
create mode 100644 config.toml
create mode 100644 content/_index.md
create mode 100644 content/notes/CJK + Latex Support (测试).md
create mode 100644 content/notes/config.md
create mode 100644 content/notes/custom Domain.md
create mode 100644 content/notes/editing.md
create mode 100644 content/notes/hosting.md
create mode 100644 content/notes/ignore notes.md
create mode 100644 content/notes/images/github-actions.png
create mode 100644 content/notes/images/github-pages.png
create mode 100644 content/notes/images/google-domains.png
create mode 100644 content/notes/images/obsidian-settings.png
create mode 100644 content/notes/obsidian.md
create mode 100644 content/notes/philosophy.md
create mode 100644 content/notes/preview changes.md
create mode 100644 content/notes/setup.md
create mode 100644 content/notes/showcase.md
create mode 100644 content/notes/troubleshooting.md
create mode 100644 content/private/private-note.md
create mode 100644 content/templates/post.md
create mode 100644 data/config.yaml
create mode 100644 data/graphConfig.yaml
create mode 100644 layouts/404.html
create mode 100644 layouts/_default/_markup/render-image.html
create mode 100644 layouts/_default/_markup/render-link.html
create mode 100644 layouts/_default/baseof.html
create mode 100644 layouts/_default/section.html
create mode 100644 layouts/_default/single.html
create mode 100644 layouts/_default/taxonomy.html
create mode 100644 layouts/_default/term.html
create mode 100644 layouts/index.html
create mode 100644 layouts/partials/backlinks.html
create mode 100644 layouts/partials/contact.html
create mode 100644 layouts/partials/darkmode.html
create mode 100644 layouts/partials/footer.html
create mode 100644 layouts/partials/graph.html
create mode 100644 layouts/partials/head.html
create mode 100644 layouts/partials/katex.html
create mode 100644 layouts/partials/page-list.html
create mode 100644 layouts/partials/popover.html
create mode 100644 layouts/partials/search.html
create mode 100644 layouts/partials/textprocessing.html
create mode 100644 layouts/partials/toc.html
create mode 100644 screenshot.png
create mode 100644 static/icon.png
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..40b2d4a
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1 @@
+github: [jackyzha0]
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..189648d
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,32 @@
+---
+name: Bug report
+about: Something about Quartz isn't working the way you expect
+title: ''
+labels: bug
+assignees: ''
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior:
+1. Go to '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**Desktop (please complete the following information):**
+ - Device: [e.g. iPhone6]
+ - OS: [e.g. iOS]
+ - Browser [e.g. chrome, safari]
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000..2c9c226
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
+---
+name: Feature request
+about: Suggest an idea or improvement for Quartz
+title: ''
+labels: enhancement
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml
new file mode 100644
index 0000000..6a22367
--- /dev/null
+++ b/.github/workflows/deploy.yaml
@@ -0,0 +1,37 @@
+name: Deploy to GitHub Pages
+
+on:
+ push:
+ branches:
+ - hugo
+
+jobs:
+ deploy:
+ runs-on: ubuntu-18.04
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Build Link Index
+ uses: jackyzha0/hugo-obsidian@v2.12
+ with:
+ index: true
+ input: content
+ output: assets/indices
+ root: .
+
+ - name: Setup Hugo
+ uses: peaceiris/actions-hugo@v2
+ with:
+ hugo-version: '0.96.0'
+ extended: true
+
+ - name: Build
+ run: hugo --minify
+
+ - name: Deploy
+ uses: peaceiris/actions-gh-pages@v3
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ publish_dir: ./public
+ publish_branch: master # deploying branch
+ cname: quartz.jzhao.xyz
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a7ccdb5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+.DS_Store
+public
+resources
+.idea
+content/.obsidian
+assets/indices/linkIndex.json
+assets/indices/contentIndex.json
diff --git a/.hugo_build.lock b/.hugo_build.lock
new file mode 100644
index 0000000..e69de29
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..c624fd5
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,93 @@
+# Citizen Code of Conduct
+
+## 1. Purpose
+
+A primary goal of the Quartz community is to be inclusive to the largest number of contributors, with the most varied and diverse backgrounds possible. As such, we are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof).
+
+This code of conduct outlines our expectations for all those who participate in our community, as well as the consequences for unacceptable behavior.
+
+We invite all those who participate in the Quartz community to help us create safe and positive experiences for everyone.
+
+## 2. Open [Source/Culture/Tech] Citizenship
+
+A supplemental goal of this Code of Conduct is to increase open [source/culture/tech] citizenship by encouraging participants to recognize and strengthen the relationships between our actions and their effects on our community.
+
+Communities mirror the societies in which they exist and positive action is essential to counteract the many forms of inequality and abuses of power that exist in society.
+
+If you see someone who is making an extra effort to ensure our community is welcoming, friendly, and encourages all participants to contribute to the fullest extent, we want to know.
+
+## 3. Expected Behavior
+
+The following behaviors are expected and requested of all community members:
+
+ * Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community.
+ * Exercise consideration and respect in your speech and actions.
+ * Attempt collaboration before conflict.
+ * Refrain from demeaning, discriminatory, or harassing behavior and speech.
+ * Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential.
+ * Remember that community event venues may be shared with members of the public; please be respectful to all patrons of these locations.
+
+## 4. Unacceptable Behavior
+
+The following behaviors are considered harassment and are unacceptable within our community:
+
+ * Violence, threats of violence or violent language directed against another person.
+ * Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language.
+ * Posting or displaying sexually explicit or violent material.
+ * Posting or threatening to post other people's personally identifying information ("doxing").
+ * Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability.
+ * Inappropriate photography or recording.
+ * Inappropriate physical contact. You should have someone's consent before touching them.
+ * Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, and unwelcomed sexual advances.
+ * Deliberate intimidation, stalking or following (online or in person).
+ * Advocating for, or encouraging, any of the above behavior.
+ * Sustained disruption of community events, including talks and presentations.
+
+## 5. Weapons Policy
+
+No weapons will be allowed at Quartz community events, community spaces, or in other spaces covered by the scope of this Code of Conduct. Weapons include but are not limited to guns, explosives (including fireworks), and large knives such as those used for hunting or display, as well as any other item used for the purpose of causing injury or harm to others. Anyone seen in possession of one of these items will be asked to leave immediately, and will only be allowed to return without the weapon. Community members are further expected to comply with all state and local laws on this matter.
+
+## 6. Consequences of Unacceptable Behavior
+
+Unacceptable behavior from any community member, including sponsors and those with decision-making authority, will not be tolerated.
+
+Anyone asked to stop unacceptable behavior is expected to comply immediately.
+
+If a community member engages in unacceptable behavior, the community organizers may take any action they deem appropriate, up to and including a temporary ban or permanent expulsion from the community without warning (and without refund in the case of a paid event).
+
+## 7. Reporting Guidelines
+
+If you are subject to or witness unacceptable behavior, or have any other concerns, please notify a community organizer as soon as possible. j.zhao2k19@gmail.com.
+
+
+
+Additionally, community organizers are available to help community members engage with local law enforcement or to otherwise help those experiencing unacceptable behavior feel safe. In the context of in-person events, organizers will also provide escorts as desired by the person experiencing distress.
+
+## 8. Addressing Grievances
+
+If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify @jackyzha0 with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies.
+
+
+## 9. Scope
+
+We expect all community participants (contributors, paid or otherwise; sponsors; and other guests) to abide by this Code of Conduct in all community venues--online and in-person--as well as in all one-on-one communications pertaining to community business.
+
+This code of conduct and its related procedures also applies to unacceptable behavior occurring outside the scope of community activities when such behavior has the potential to adversely affect the safety and well-being of community members.
+
+## 10. Contact info
+
+j.zhao2k19@gmail.com
+
+## 11. License and attribution
+
+The Citizen Code of Conduct is distributed by [Stumptown Syndicate](http://stumptownsyndicate.org) under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/).
+
+Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy).
+
+_Revision 2.3. Posted 6 March 2017._
+
+_Revision 2.2. Posted 4 February 2016._
+
+_Revision 2.1. Posted 23 June 2014._
+
+_Revision 2.0, adopted by the [Stumptown Syndicate](http://stumptownsyndicate.org) board on 10 January 2013. Posted 17 March 2013._
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..147e2ca
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2021 jackyzha0
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9beee0f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,18 @@
+.DEFAULT_GOAL := serve
+
+help: ## Show all Makefile targets
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
+
+update: ## Update Quartz to the latest version on Github
+ @git remote show upstream || (echo "remote 'upstream' not present, setting 'upstream'" && git remote add upstream https://github.com/jackyzha0/quartz.git)
+ git fetch upstream
+ git log --oneline --decorate --graph ..upstream/hugo
+ git checkout -p upstream/hugo -- layouts .github Makefile assets/js assets/styles/base.scss assets/styles/darkmode.scss config.toml data
+
+update-force: ## Forcefully pull all changes and don't ask to patch
+ @git remote show upstream || (echo "remote 'upstream' not present, setting 'upstream'" && git remote add upstream https://github.com/jackyzha0/quartz.git)
+ git fetch upstream
+ git checkout upstream/hugo -- layouts .github Makefile assets/js assets/styles/base.scss assets/styles/darkmode.scss config.toml data
+
+serve: ## Serve Quartz locally
+ hugo-obsidian -input=content -output=assets/indices -index -root=. && hugo server --enableGitInfo
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..125514a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,17 @@
+# Quartz
+
+Host your second brain and [digital garden](https://jzhao.xyz/posts/digital-gardening) for free. Quartz features
+
+1. Extremely fast full-text search by pressing `Ctrl` + `k`
+2. Customizable and hackable design based on Hugo
+3. Automatically generated backlinks, link previews, and local graph
+4. Built-in CJK + Latex Support
+5. Support for both Markdown Links and Wikilinks
+
+> “[One] who works with the door open gets all kinds of interruptions, but [they] also occasionally gets clues as to what the world is and what might be important.” — Richard Hamming
+
+🔗 Get Started: https://quartz.jzhao.xyz/
+
+![Quartz Example Screenshot](./screenshot.png)*Quartz Example Screenshot*
+
+[Join the Discord Community](https://discord.gg/cRFFHYye7t)
diff --git a/assets/indices/.gitkeep b/assets/indices/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/assets/js/darkmode.js b/assets/js/darkmode.js
new file mode 100644
index 0000000..d95a281
--- /dev/null
+++ b/assets/js/darkmode.js
@@ -0,0 +1,29 @@
+const userPref = window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark'
+const currentTheme = localStorage.getItem('theme') ?? userPref
+
+if (currentTheme) {
+ document.documentElement.setAttribute('saved-theme', currentTheme);
+}
+
+const switchTheme = (e) => {
+ if (e.target.checked) {
+ document.documentElement.setAttribute('saved-theme', 'dark')
+ localStorage.setItem('theme', 'dark')
+ }
+ else {
+ document.documentElement.setAttribute('saved-theme', 'light')
+ localStorage.setItem('theme', 'light')
+ }
+}
+
+window.addEventListener('DOMContentLoaded', () => {
+ // Darkmode toggle
+ const toggleSwitch = document.querySelector('#darkmode-toggle')
+
+ // listen for toggle
+ toggleSwitch.addEventListener('change', switchTheme, false)
+
+ if (currentTheme === 'dark') {
+ toggleSwitch.checked = true
+ }
+})
diff --git a/assets/js/graph.js b/assets/js/graph.js
new file mode 100644
index 0000000..f0b1f7f
--- /dev/null
+++ b/assets/js/graph.js
@@ -0,0 +1,220 @@
+async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLegend, enableZoom) {
+ const { index, links, content } = await fetchData
+ const curPage = url.replace(baseUrl, "")
+
+ const parseIdsFromLinks = (links) => [...(new Set(links.flatMap(link => ([link.source, link.target]))))]
+
+ const neighbours = new Set()
+ const wl = [curPage || "/", "__SENTINEL"]
+ if (depth >= 0) {
+ while (depth >= 0 && wl.length > 0) {
+ // compute neighbours
+ const cur = wl.shift()
+ if (cur === "__SENTINEL") {
+ depth--
+ wl.push("__SENTINEL")
+ } else {
+ neighbours.add(cur)
+ const outgoing = index.links[cur] || []
+ const incoming = index.backlinks[cur] || []
+ wl.push(...outgoing.map(l => l.target), ...incoming.map(l => l.source))
+ }
+ }
+ } else {
+ parseIdsFromLinks(links).forEach(id => neighbours.add(id))
+ }
+
+ const data = {
+ nodes: [...neighbours].map(id => ({ id })),
+ links: links.filter(l => neighbours.has(l.source) && neighbours.has(l.target)),
+ }
+
+ const color = (d) => {
+ if (d.id === curPage || (d.id === "/" && curPage === "")) {
+ return "var(--g-node-active)"
+ }
+
+ for (const pathColor of pathColors) {
+ const path = Object.keys(pathColor)[0]
+ const colour = pathColor[path]
+ if (d.id.startsWith(path)) {
+ return colour
+ }
+ }
+
+ return "var(--g-node)"
+ }
+
+ const drag = simulation => {
+ function dragstarted(event, d) {
+ if (!event.active) simulation.alphaTarget(1).restart();
+ d.fx = d.x;
+ d.fy = d.y;
+ }
+
+ function dragged(event, d) {
+ d.fx = event.x;
+ d.fy = event.y;
+ }
+
+ function dragended(event, d) {
+ if (!event.active) simulation.alphaTarget(0);
+ d.fx = null;
+ d.fy = null;
+ }
+
+ const noop = () => { }
+ return d3.drag()
+ .on("start", enableDrag ? dragstarted : noop)
+ .on("drag", enableDrag ? dragged : noop)
+ .on("end", enableDrag ? dragended : noop);
+ }
+
+ const height = 250
+ const width = document.getElementById("graph-container").offsetWidth
+
+ const simulation = d3.forceSimulation(data.nodes)
+ .force("charge", d3.forceManyBody().strength(-30))
+ .force("link", d3.forceLink(data.links).id(d => d.id))
+ .force("center", d3.forceCenter());
+
+ const svg = d3.select('#graph-container')
+ .append('svg')
+ .attr('width', width)
+ .attr('height', height)
+ .attr("viewBox", [-width / 2, -height / 2, width, height]);
+
+ if (enableLegend) {
+ const legend = [
+ { "Current": "var(--g-node-active)" },
+ { "Note": "var(--g-node)" },
+ ...pathColors
+ ]
+ legend.forEach((legendEntry, i) => {
+ const key = Object.keys(legendEntry)[0]
+ const colour = legendEntry[key]
+ svg.append("circle").attr("cx", -width / 2 + 20).attr("cy", height / 2 - 30 * (i + 1)).attr("r", 6).style("fill", colour)
+ svg.append("text").attr("x", -width / 2 + 40).attr("y", height / 2 - 30 * (i + 1)).text(key).style("font-size", "15px").attr("alignment-baseline", "middle")
+ })
+ }
+
+ // draw links between nodes
+ const link = svg.append("g")
+ .selectAll("line")
+ .data(data.links)
+ .join("line")
+ .attr("class", "link")
+ .attr("stroke", "var(--g-link)")
+ .attr("stroke-width", 2)
+ .attr("data-source", d => d.source.id)
+ .attr("data-target", d => d.target.id)
+
+ // svg groups
+ const graphNode = svg.append("g")
+ .selectAll("g")
+ .data(data.nodes)
+ .enter().append("g")
+
+ // draw individual nodes
+ const node = graphNode.append("circle")
+ .attr("class", "node")
+ .attr("id", (d) => d.id)
+ .attr("r", (d) => {
+ const numOut = index.links[d.id]?.length || 0
+ const numIn = index.backlinks[d.id]?.length || 0
+ return 3 + (numOut + numIn) / 4
+ })
+ .attr("fill", color)
+ .style("cursor", "pointer")
+ .on("click", (_, d) => {
+ window.location.href = baseUrl + '/' + decodeURI(d.id).replace(/\s+/g, '-')
+ })
+ .on("mouseover", function(_, d) {
+ d3.selectAll(".node")
+ .transition()
+ .duration(100)
+ .attr("fill", "var(--g-node-inactive)")
+
+ const neighbours = parseIdsFromLinks([...(index.links[d.id] || []), ...(index.backlinks[d.id] || [])])
+ const neighbourNodes = d3.selectAll(".node").filter(d => neighbours.includes(d.id))
+ const currentId = d.id
+ const linkNodes = d3.selectAll(".link").filter(d => d.source.id === currentId || d.target.id === currentId)
+
+ // highlight neighbour nodes
+ neighbourNodes
+ .transition()
+ .duration(200)
+ .attr("fill", color)
+
+ // highlight links
+ linkNodes
+ .transition()
+ .duration(200)
+ .attr("stroke", "var(--g-link-active)")
+
+ // show text for self
+ d3.select(this.parentNode)
+ .select("text")
+ .raise()
+ .transition()
+ .duration(200)
+ .style("opacity", 1)
+ }).on("mouseleave", function(_, d) {
+ d3.selectAll(".node")
+ .transition()
+ .duration(200)
+ .attr("fill", color)
+
+ const currentId = d.id
+ const linkNodes = d3.selectAll(".link").filter(d => d.source.id === currentId || d.target.id === currentId)
+
+ linkNodes
+ .transition()
+ .duration(200)
+ .attr("stroke", "var(--g-link)")
+
+ d3.select(this.parentNode)
+ .select("text")
+ .transition()
+ .duration(200)
+ .style("opacity", 0)
+ })
+ .call(drag(simulation));
+
+ // draw labels
+ const labels = graphNode.append("text")
+ .attr("dx", 12)
+ .attr("dy", ".35em")
+ .text((d) => content[d.id]?.title || d.id.replace("-", " "))
+ .style("opacity", 0)
+ .style("pointer-events", "none")
+ .call(drag(simulation));
+
+ // set panning
+
+ if (enableZoom) {
+ svg.call(d3.zoom()
+ .extent([[0, 0], [width, height]])
+ .scaleExtent([0.25, 4])
+ .on("zoom", ({ transform }) => {
+ link.attr("transform", transform);
+ node.attr("transform", transform);
+ labels.attr("transform", transform);
+ }));
+ }
+
+ // progress the simulation
+ simulation.on("tick", () => {
+ link
+ .attr("x1", d => d.source.x)
+ .attr("y1", d => d.source.y)
+ .attr("x2", d => d.target.x)
+ .attr("y2", d => d.target.y)
+ node
+ .attr("cx", d => d.x)
+ .attr("cy", d => d.y)
+ labels
+ .attr("x", d => d.x)
+ .attr("y", d => d.y)
+ });
+}
diff --git a/assets/js/popover.js b/assets/js/popover.js
new file mode 100644
index 0000000..a4b6852
--- /dev/null
+++ b/assets/js/popover.js
@@ -0,0 +1,35 @@
+function htmlToElement(html) {
+ const template = document.createElement('template')
+ html = html.trim()
+ template.innerHTML = html
+ return template.content.firstChild
+}
+
+function initPopover(baseURL) {
+ const basePath = baseURL.replace(window.location.origin, "")
+ document.addEventListener("DOMContentLoaded", () => {
+ fetchData.then(({ content }) => {
+ const links = [...document.getElementsByClassName("internal-link")]
+ links
+ .filter(li => li.dataset.src)
+ .forEach(li => {
+ const linkDest = content[li.dataset.src.replace(basePath, "")]
+ if (linkDest) {
+ const popoverElement = `