Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14c6181d24 | ||
|
|
e6e04c03c4 | ||
|
|
146e975932 | ||
|
|
c117e38899 | ||
|
|
4fd983277e | ||
|
|
cc86136bcb | ||
|
|
8e083d4a93 | ||
|
|
03b574b160 | ||
|
|
a469653f75 | ||
|
|
c51573efa9 | ||
|
|
902d0f2a0f | ||
|
|
1ddd15afc6 | ||
|
|
16f8cd7100 | ||
|
|
9c5ecccf25 | ||
|
|
e3cd531c53 | ||
|
|
3674df48b8 | ||
|
|
9e8c5587e4 | ||
|
|
6605b13b86 | ||
|
|
6edc979896 | ||
|
|
fc43922445 | ||
|
|
54a68e6e5c | ||
|
|
a6ab2f92ef | ||
|
|
fda481fbb9 | ||
|
|
94e987dab5 | ||
|
|
e981c76ed4 | ||
|
|
f70128a3de | ||
|
|
651bfc5cd2 | ||
|
|
6079420178 | ||
|
|
b96c60edfc | ||
|
|
978d5ca1ae | ||
|
|
907270992d | ||
|
|
6f9283e95b | ||
|
|
0fad5570d3 | ||
|
|
dc9b421e21 | ||
|
|
8779e72c77 | ||
|
|
7f6523337c | ||
|
|
7e0f2e4449 | ||
|
|
1313bd9779 | ||
|
|
5234fae080 | ||
|
|
0ee0855e1c | ||
|
|
e06e341468 | ||
|
|
73e526a7d5 | ||
|
|
cdc4f1a840 | ||
|
|
714b4fcfa3 | ||
|
|
9c04ca0266 | ||
|
|
388a2bf78b | ||
|
|
f192f9a23d | ||
|
|
3b3e6ec3b2 | ||
|
|
8e85e274f6 | ||
|
|
fcd5d2807d | ||
|
|
4587b13360 | ||
|
|
fb9ea8dcb8 | ||
|
|
c520db4882 | ||
|
|
10f9843bb6 | ||
|
|
0dc51ff39c | ||
|
|
c35086c510 | ||
|
|
31297b7e5a | ||
|
|
fa3bc3de92 | ||
|
|
41c443dbf0 | ||
|
|
a271fb9d74 | ||
|
|
49cdca5dfc | ||
|
|
9645f00317 | ||
|
|
57ebf4c21c | ||
|
|
54e3e071d1 | ||
|
|
d46e223831 | ||
|
|
6f9a29c174 | ||
|
|
532bc61025 | ||
|
|
99aea48260 |
7
.github/workflows/deploy.yaml
vendored
7
.github/workflows/deploy.yaml
vendored
@@ -12,16 +12,17 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Build Link Index
|
- name: Build Link Index
|
||||||
uses: jackyzha0/hugo-obsidian@v2.7
|
uses: jackyzha0/hugo-obsidian@v2.12
|
||||||
with:
|
with:
|
||||||
index: true
|
index: true
|
||||||
input: content
|
input: content
|
||||||
output: data
|
output: assets/indices
|
||||||
|
root: .
|
||||||
|
|
||||||
- name: Setup Hugo
|
- name: Setup Hugo
|
||||||
uses: peaceiris/actions-hugo@v2
|
uses: peaceiris/actions-hugo@v2
|
||||||
with:
|
with:
|
||||||
hugo-version: '0.82.0'
|
hugo-version: '0.92.2'
|
||||||
extended: true
|
extended: true
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
|
|||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,5 +3,5 @@ public
|
|||||||
resources
|
resources
|
||||||
.idea
|
.idea
|
||||||
content/.obsidian
|
content/.obsidian
|
||||||
data/linkIndex.yaml
|
assets/indices/linkIndex.json
|
||||||
data/contentIndex.yaml
|
assets/indices/contentIndex.json
|
||||||
|
|||||||
0
.hugo_build.lock
Normal file
0
.hugo_build.lock
Normal file
2
Makefile
2
Makefile
@@ -4,4 +4,4 @@ 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}'
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||||
|
|
||||||
serve: ## serve
|
serve: ## serve
|
||||||
hugo-obsidian -input=content -output=data -index -root=. && hugo server
|
hugo-obsidian -input=content -output=assets/indices -index -root=. && hugo server --enableGitInfo
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -1,6 +1,16 @@
|
|||||||
# Quartz
|
# Quartz
|
||||||
Host your own second brain and digital garden for free.
|
|
||||||
|
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 `/`
|
||||||
|
2. Display for backlinks of each note
|
||||||
|
3. Fully customizable local graph view
|
||||||
|
4. Endlessly powerful page and theme customization using CSS
|
||||||
|
5. Automatically generated tag and section lists of content
|
||||||
|
6. Beautiful link previews
|
||||||
|
|
||||||
> “[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
|
> “[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/
|
🔗 Get Started: https://quartz.jzhao.xyz/
|
||||||
|
|
||||||
|
*Quartz Example Screenshot*
|
||||||
0
assets/indices/.gitkeep
Normal file
0
assets/indices/.gitkeep
Normal file
220
assets/js/graph.js
Normal file
220
assets/js/graph.js
Normal file
@@ -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)
|
||||||
|
});
|
||||||
|
}
|
||||||
33
assets/js/popover.js
Normal file
33
assets/js/popover.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
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.forEach(li => {
|
||||||
|
const linkDest = content[li.dataset.src.replace(basePath, "")]
|
||||||
|
if (linkDest) {
|
||||||
|
const popoverElement = `<div class="popover">
|
||||||
|
<h3>${linkDest.title}</h3>
|
||||||
|
<p>${removeMarkdown(linkDest.content).split(" ", 20).join(" ")}...</p>
|
||||||
|
<p class="meta">${new Date(linkDest.lastmodified).toLocaleDateString()}</p>
|
||||||
|
</div>`
|
||||||
|
const el = htmlToElement(popoverElement)
|
||||||
|
li.appendChild(el)
|
||||||
|
li.addEventListener("mouseover", () => {
|
||||||
|
el.classList.add("visible")
|
||||||
|
})
|
||||||
|
li.addEventListener("mouseout", () => {
|
||||||
|
el.classList.remove("visible")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
239
assets/js/search.js
Normal file
239
assets/js/search.js
Normal file
@@ -0,0 +1,239 @@
|
|||||||
|
// code from https://github.com/danestves/markdown-to-text
|
||||||
|
const removeMarkdown = (
|
||||||
|
markdown,
|
||||||
|
options = {
|
||||||
|
listUnicodeChar: false,
|
||||||
|
stripListLeaders: true,
|
||||||
|
gfm: true,
|
||||||
|
useImgAltText: false,
|
||||||
|
preserveLinks: false,
|
||||||
|
}
|
||||||
|
) => {
|
||||||
|
let output = markdown || "";
|
||||||
|
output = output.replace(/^(-\s*?|\*\s*?|_\s*?){3,}\s*$/gm, "");
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (options.stripListLeaders) {
|
||||||
|
if (options.listUnicodeChar)
|
||||||
|
output = output.replace(
|
||||||
|
/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm,
|
||||||
|
options.listUnicodeChar + " $1"
|
||||||
|
);
|
||||||
|
else output = output.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm, "$1");
|
||||||
|
}
|
||||||
|
if (options.gfm) {
|
||||||
|
output = output
|
||||||
|
.replace(/\n={2,}/g, "\n")
|
||||||
|
.replace(/~{3}.*\n/g, "")
|
||||||
|
.replace(/~~/g, "")
|
||||||
|
.replace(/`{3}.*\n/g, "");
|
||||||
|
}
|
||||||
|
if (options.preserveLinks) {
|
||||||
|
output = output.replace(/\[(.*?)\][\[\(](.*?)[\]\)]/g, "$1 ($2)")
|
||||||
|
}
|
||||||
|
output = output
|
||||||
|
.replace(/<[^>]*>/g, "")
|
||||||
|
.replace(/^[=\-]{2,}\s*$/g, "")
|
||||||
|
.replace(/\[\^.+?\](\: .*?$)?/g, "")
|
||||||
|
.replace(/\s{0,2}\[.*?\]: .*?$/g, "")
|
||||||
|
.replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, options.useImgAltText ? "$1" : "")
|
||||||
|
.replace(/\[(.*?)\][\[\(].*?[\]\)]/g, "$1")
|
||||||
|
.replace(/^\s{0,3}>\s?/g, "")
|
||||||
|
.replace(/(^|\n)\s{0,3}>\s?/g, "\n\n")
|
||||||
|
.replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g, "")
|
||||||
|
.replace(
|
||||||
|
/^(\n)?\s{0,}#{1,6}\s+| {0,}(\n)?\s{0,}#{0,} {0,}(\n)?\s{0,}$/gm,
|
||||||
|
"$1$2$3"
|
||||||
|
)
|
||||||
|
.replace(/([\*_]{1,3})(\S.*?\S{0,1})\1/g, "$2")
|
||||||
|
.replace(/([\*_]{1,3})(\S.*?\S{0,1})\1/g, "$2")
|
||||||
|
.replace(/(`{3,})(.*?)\1/gm, "$2")
|
||||||
|
.replace(/`(.+?)`/g, "$1")
|
||||||
|
.replace(/\n{2,}/g, "\n\n");
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
return markdown;
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
// -----
|
||||||
|
|
||||||
|
(async function() {
|
||||||
|
const encoder = str => str.toLowerCase().split(/([^a-z]|[^\x00-\x7F])+/)
|
||||||
|
const contentIndex = new FlexSearch.Document({
|
||||||
|
cache: true,
|
||||||
|
charset: "latin:extra",
|
||||||
|
optimize: true,
|
||||||
|
index: [{
|
||||||
|
field: "content",
|
||||||
|
tokenize: "reverse",
|
||||||
|
encode: encoder,
|
||||||
|
}, {
|
||||||
|
field: "title",
|
||||||
|
tokenize: "forward",
|
||||||
|
encode: encoder,
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
const { content } = await fetchData
|
||||||
|
for (const [key, value] of Object.entries(content)) {
|
||||||
|
contentIndex.add({
|
||||||
|
id: key,
|
||||||
|
title: value.title,
|
||||||
|
content: removeMarkdown(value.content),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const highlight = (content, term) => {
|
||||||
|
const highlightWindow = 20
|
||||||
|
const tokenizedTerm = term.split(/\s+/).filter(t => t !== "")
|
||||||
|
const splitText = content.split(/\s+/).filter(t => t !== "")
|
||||||
|
const includesCheck = (token) => tokenizedTerm.some(term => token.toLowerCase().startsWith(term.toLowerCase()))
|
||||||
|
|
||||||
|
const occurrencesIndices = splitText
|
||||||
|
.map(includesCheck)
|
||||||
|
|
||||||
|
// calculate best index
|
||||||
|
let bestSum = 0
|
||||||
|
let bestIndex = 0
|
||||||
|
for (let i = 0; i < Math.max(occurrencesIndices.length - highlightWindow, 0); i++) {
|
||||||
|
const window = occurrencesIndices.slice(i, i + highlightWindow)
|
||||||
|
const windowSum = window.reduce((total, cur) => total + cur, 0)
|
||||||
|
if (windowSum >= bestSum) {
|
||||||
|
bestSum = windowSum
|
||||||
|
bestIndex = i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const startIndex = Math.max(bestIndex - highlightWindow, 0)
|
||||||
|
const endIndex = Math.min(startIndex + 2 * highlightWindow, splitText.length)
|
||||||
|
const mappedText = splitText
|
||||||
|
.slice(startIndex, endIndex)
|
||||||
|
.map(token => {
|
||||||
|
if (includesCheck(token)) {
|
||||||
|
return `<span class="search-highlight">${token}</span>`
|
||||||
|
}
|
||||||
|
return token
|
||||||
|
})
|
||||||
|
.join(" ")
|
||||||
|
.replaceAll('</span> <span class="search-highlight">', " ")
|
||||||
|
return `${startIndex === 0 ? "" : "..."}${mappedText}${endIndex === splitText.length ? "" : "..."}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const resultToHTML = ({ url, title, content, term }) => {
|
||||||
|
const text = removeMarkdown(content)
|
||||||
|
const resultTitle = highlight(title, term)
|
||||||
|
const resultText = highlight(text, term)
|
||||||
|
return `<button class="result-card" id="${url}">
|
||||||
|
<h3>${resultTitle}</h3>
|
||||||
|
<p>${resultText}</p>
|
||||||
|
</button>`
|
||||||
|
}
|
||||||
|
|
||||||
|
const redir = (id, term) => {
|
||||||
|
window.location.href = BASE_URL + `${id}#:~:text=${encodeURIComponent(term)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatForDisplay = id => ({
|
||||||
|
id,
|
||||||
|
url: id,
|
||||||
|
title: content[id].title,
|
||||||
|
content: content[id].content
|
||||||
|
})
|
||||||
|
|
||||||
|
const source = document.getElementById('search-bar')
|
||||||
|
const results = document.getElementById("results-container")
|
||||||
|
let term
|
||||||
|
source.addEventListener("keyup", (e) => {
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
const anchor = document.getElementsByClassName("result-card")[0]
|
||||||
|
redir(anchor.id, term)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
source.addEventListener('input', (e) => {
|
||||||
|
term = e.target.value
|
||||||
|
const searchResults = contentIndex.search(term, [
|
||||||
|
{
|
||||||
|
field: "content",
|
||||||
|
limit: 10,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: "title",
|
||||||
|
limit: 5,
|
||||||
|
}
|
||||||
|
])
|
||||||
|
const getByField = field => {
|
||||||
|
const results = searchResults.filter(x => x.field === field)
|
||||||
|
if (results.length === 0) {
|
||||||
|
return []
|
||||||
|
} else {
|
||||||
|
return [...results[0].result]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const allIds = new Set([...getByField('title'), ...getByField('content')])
|
||||||
|
const finalResults = [...allIds].map(formatForDisplay)
|
||||||
|
|
||||||
|
// display
|
||||||
|
if (finalResults.length === 0) {
|
||||||
|
results.innerHTML = `<button class="result-card">
|
||||||
|
<h3>No results.</h3>
|
||||||
|
<p>Try another search term?</p>
|
||||||
|
</button>`
|
||||||
|
} else {
|
||||||
|
results.innerHTML = finalResults
|
||||||
|
.map(result => resultToHTML({
|
||||||
|
...result,
|
||||||
|
term,
|
||||||
|
}))
|
||||||
|
.join("\n")
|
||||||
|
const anchors = document.getElementsByClassName("result-card");
|
||||||
|
[...anchors].forEach(anchor => {
|
||||||
|
anchor.onclick = () => redir(anchor.id, term)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const searchContainer = document.getElementById("search-container")
|
||||||
|
|
||||||
|
function openSearch() {
|
||||||
|
if (searchContainer.style.display === "none" || searchContainer.style.display === "") {
|
||||||
|
source.value = ""
|
||||||
|
results.innerHTML = ""
|
||||||
|
searchContainer.style.display = "block"
|
||||||
|
source.focus()
|
||||||
|
} else {
|
||||||
|
searchContainer.style.display = "none"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeSearch() {
|
||||||
|
searchContainer.style.display = "none"
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('keydown', (event) => {
|
||||||
|
if (event.key === "k" && (event.ctrlKey || event.metaKey)) {
|
||||||
|
event.preventDefault()
|
||||||
|
openSearch()
|
||||||
|
}
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
event.preventDefault()
|
||||||
|
closeSearch()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const searchButton = document.getElementById("search-icon")
|
||||||
|
searchButton.addEventListener('click', (evt) => {
|
||||||
|
openSearch()
|
||||||
|
})
|
||||||
|
searchButton.addEventListener('keydown', (evt) => {
|
||||||
|
openSearch()
|
||||||
|
})
|
||||||
|
searchContainer.addEventListener('click', (evt) => {
|
||||||
|
closeSearch()
|
||||||
|
})
|
||||||
|
document.getElementById("search-space").addEventListener('click', (evt) => {
|
||||||
|
evt.stopPropagation()
|
||||||
|
})
|
||||||
|
})()
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
--lt-colours-gray: var(--outlinegray) !important;
|
--lt-colours-gray: var(--outlinegray) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h2, h3, h4, ol, ul, thead {
|
h1, h2, h3, h4, h5, h6, ol, ul, thead {
|
||||||
font-family: Inter;
|
font-family: Inter;
|
||||||
color: var(--dark);
|
color: var(--dark);
|
||||||
font-weight: revert;
|
font-weight: revert;
|
||||||
@@ -81,10 +81,6 @@ p, tbody, li {
|
|||||||
line-height: 1.5em;
|
line-height: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2, h3 {
|
|
||||||
opacity: 0.9;
|
|
||||||
}
|
|
||||||
|
|
||||||
blockquote {
|
blockquote {
|
||||||
margin-left: 0em;
|
margin-left: 0em;
|
||||||
border-left: 3px solid var(--secondary);
|
border-left: 3px solid var(--secondary);
|
||||||
@@ -116,6 +112,10 @@ td, th {
|
|||||||
gap: 1.5em;
|
gap: 1.5em;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
|
.disabled {
|
||||||
|
opacity: 0.2;
|
||||||
|
}
|
||||||
|
|
||||||
& > li {
|
& > li {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@@ -185,10 +185,19 @@ article {
|
|||||||
padding: 0 0.1em;
|
padding: 0 0.1em;
|
||||||
margin: auto -0.1em;
|
margin: auto -0.1em;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
|
||||||
|
&.broken {
|
||||||
|
opacity: 0.5;
|
||||||
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
& p {
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.backlinks a {
|
.backlinks a {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
@@ -229,13 +238,22 @@ code {
|
|||||||
|
|
||||||
html {
|
html {
|
||||||
scroll-behavior: smooth;
|
scroll-behavior: smooth;
|
||||||
|
|
||||||
|
&:lang(ar) {
|
||||||
|
& p, & h1, & h2, & h3, article {
|
||||||
|
direction: rtl;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
overflow-x: hidden;
|
//overflow-x: hidden;
|
||||||
|
max-width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
background-color: var(--light);
|
background-color: var(--light);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,10 +283,10 @@ hr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.singlePage {
|
.singlePage {
|
||||||
margin: 4em 30vw;
|
padding: 4em 30vw;
|
||||||
|
|
||||||
@media all and (max-width: 1200px) {
|
@media all and (max-width: 1200px) {
|
||||||
margin: 25px 5vw;
|
padding: 25px 5vw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,8 +485,9 @@ header {
|
|||||||
.popover {
|
.popover {
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 15em;
|
width: 20em;
|
||||||
display: inline;
|
display: inline-block;
|
||||||
|
visibility: hidden;
|
||||||
background-color: var(--light);
|
background-color: var(--light);
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
border: 1px solid var(--outlinegray);
|
border: 1px solid var(--outlinegray);
|
||||||
@@ -480,17 +499,41 @@ header {
|
|||||||
transition-delay: 0.3s;
|
transition-delay: 0.3s;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
||||||
|
@media all and (max-width: 600px) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
&.visible {
|
&.visible {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
transform: translate(-50%, 20%);
|
transform: translate(-50%, 20%);
|
||||||
}
|
}
|
||||||
|
|
||||||
& > h3 {
|
& > h3 {
|
||||||
margin: 0.5em 0;
|
font-size: 1rem;
|
||||||
|
margin: 0.25em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
& > .meta {
|
||||||
|
margin-top: 0.25em;
|
||||||
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
& > p {
|
& > p {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#contact_buttons ul {
|
||||||
|
list-style-type: none;
|
||||||
|
|
||||||
|
li {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
li a {
|
||||||
|
padding: 0 1em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
---
|
---
|
||||||
title: 🪴 Quartz 3
|
title: 🪴 Quartz 3.2
|
||||||
---
|
---
|
||||||
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 `/`
|
Host your second brain and [digital garden](https://jzhao.xyz/posts/networked-thought) for free. Quartz features
|
||||||
2. Display for backlinks of each note
|
|
||||||
3. Fully customizable local graph view
|
1. Extremely fast full-text search by pressing `Ctrl` + `k`
|
||||||
4. Endlessly powerful page and theme customization using CSS
|
2. Customizable and hackable design based on Hugo
|
||||||
5. Automatically generated tag and section lists of content
|
3. Automatically generated backlinks, link previews, and local graph
|
||||||
6. Beautiful link previews
|
4. Built-in [[notes/CJK + Latex Support (测试) | CJK + Latex Support]]
|
||||||
|
5. Support for both Markdown Links and Wikilinks
|
||||||
|
|
||||||
## Get Started
|
## Get Started
|
||||||
> 📚 [Setup your own digital garden using Quartz](notes/setup.md)
|
> 📚 [Setup your own digital garden using Quartz](notes/setup.md)
|
||||||
|
|
||||||
Not convinced yet? Look at some [community digital gardens](moc/showcase) built with Quartz, or read about [why I made Quartz](notes/philosophy.md) to begin with!
|
Not convinced yet? Look at some [community digital gardens](notes/showcase.md) built with Quartz, or read about [why I made Quartz](notes/philosophy.md) to begin with.
|
||||||
|
|
||||||
## Content Lists
|
## Content Lists
|
||||||
If you prefer browsing the contents of this site through a list instead of a graph, you can find content lists here too:
|
If you prefer browsing the contents of this site through a list instead of a graph, you can find content lists here too:
|
||||||
@@ -23,3 +24,4 @@ If you prefer browsing the contents of this site through a list instead of a gra
|
|||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
- 🚧 [Troubleshooting and FAQ](notes/troubleshooting.md)
|
- 🚧 [Troubleshooting and FAQ](notes/troubleshooting.md)
|
||||||
- 🐛 [Submit an Issue](https://github.com/jackyzha0/quartz/issues)
|
- 🐛 [Submit an Issue](https://github.com/jackyzha0/quartz/issues)
|
||||||
|
- 👀 [Discord Community](https://discord.gg/cRFFHYye7t)
|
||||||
|
|||||||
41
content/notes/CJK + Latex Support (测试).md
Normal file
41
content/notes/CJK + Latex Support (测试).md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
title: "CJK + Latex Support (测试)"
|
||||||
|
---
|
||||||
|
|
||||||
|
## Chinese, Japanese, Korean Support
|
||||||
|
几乎在我们意识到之前,我们已经离开了地面。
|
||||||
|
|
||||||
|
우리가 그것을 알기도 전에 우리는 땅을 떠났습니다.
|
||||||
|
|
||||||
|
私たちがそれを知るほぼ前に、私たちは地面を離れていました。
|
||||||
|
|
||||||
|
## Latex
|
||||||
|
|
||||||
|
Block math works with two dollar signs `$$...$$`
|
||||||
|
|
||||||
|
$$f(x) = \int_{-\infty}^\infty
|
||||||
|
f\hat(\xi),e^{2 \pi i \xi x}
|
||||||
|
\,d\xi$$
|
||||||
|
|
||||||
|
Inline math also works with single dollar signs `$...$`. For example, Euler's identity but inline: $e^{i\pi} = 0$
|
||||||
|
|
||||||
|
Aligned equations work quite well:
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{aligned}
|
||||||
|
a &= b + c \\
|
||||||
|
&= e + f \\
|
||||||
|
\end{aligned}
|
||||||
|
$$
|
||||||
|
|
||||||
|
And matrices
|
||||||
|
|
||||||
|
$$
|
||||||
|
\begin{bmatrix}
|
||||||
|
1 & 2 & 3\\
|
||||||
|
a & b & c
|
||||||
|
\end{bmatrix}
|
||||||
|
$$
|
||||||
|
|
||||||
|
## RTL
|
||||||
|
More information on configuring RTL languages like Arabic in the [config](notes/config.md) page
|
||||||
@@ -8,15 +8,16 @@ tags:
|
|||||||
Obsidian is the preferred way to use Quartz. You can either create a new Obsidian Vault or link one that your already have.
|
Obsidian is the preferred way to use Quartz. You can either create a new Obsidian Vault or link one that your already have.
|
||||||
|
|
||||||
### New Vault
|
### New Vault
|
||||||
If you don't have an existing Vault, [download Obsidian](https://obsidian.md/) and create a new Vault in the `/content` folder that you created and cloned during the [setup](notes/setup.md).
|
If you don't have an existing Vault, [download Obsidian](https://obsidian.md/) and create a new Vault in the `/content` folder that you created and cloned during the [setup](notes/setup.md) step.
|
||||||
|
|
||||||
### Linking an existing Vault
|
### Linking an existing Vault
|
||||||
The easiest way to use an existing Vault is to copy all of our files (directory and hierarchies intact) into the `/content` folder.
|
The easiest way to use an existing Vault is to copy all of your files (directory and hierarchies intact) into the `/content` folder.
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
Great, now that you have your Obsidian linked to your Quartz, let's fix some settings so that they play well.
|
Great, now that you have your Obsidian linked to your Quartz, let's fix some settings so that they play well.
|
||||||
|
|
||||||
Under Options > Files and Links, set the New link format to always be Absolute Path in Vault and disabled WikiLinks so Obsidian generates regular Markdown links.
|
1. Under Options > Files and Links, set the New link format to always be Absolute Path in Vault.
|
||||||
|
2. Go to Settings > Files & Links > Turn "on" automatically update internal links.
|
||||||
|
|
||||||
*Obsidian Settings*
|
*Obsidian Settings*
|
||||||
|
|
||||||
@@ -25,4 +26,4 @@ Inserting front matter everytime you want to create a new Note gets annoying rea
|
|||||||
|
|
||||||
**If you decide to overwrite the `/content` folder completely, don't remove the `/content/templates` folder!**
|
**If you decide to overwrite the `/content` folder completely, don't remove the `/content/templates` folder!**
|
||||||
|
|
||||||
Head over to Options > Core Plugins and enable the Templates plugin. Then go to Options > Hotkeys and set a hotkey for 'Insert Template'. That way, when you create a new note, you can just press the hotkey for a new template and be ready to go!
|
Head over to Options > Core Plugins and enable the Templates plugin. Then go to Options > Hotkeys and set a hotkey for 'Insert Template' (I recomment `[cmd]+T`). That way, when you create a new note, you can just press the hotkey for a new template and be ready to go!
|
||||||
@@ -12,6 +12,7 @@ The majority of configuration can be be found under `data/config.yaml`. An annot
|
|||||||
```yaml
|
```yaml
|
||||||
name: Your name here! # Shows in the footer
|
name: Your name here! # Shows in the footer
|
||||||
enableToc: true # Whether to show a Table of Contents
|
enableToc: true # Whether to show a Table of Contents
|
||||||
|
enableLinkPreview: true # whether to render card previews for links
|
||||||
description: Page description to show to search engines
|
description: Page description to show to search engines
|
||||||
page_title: Quartz Example Page # Default Page Title
|
page_title: Quartz Example Page # Default Page Title
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ paths: # colour specific nodes path off of their path
|
|||||||
|
|
||||||
|
|
||||||
## Styling
|
## Styling
|
||||||
Want to go even more in-depth? You can add custom CSS styling and change existing colours through editing `assets/custom.scss`. If you'd like to target specific parts of the site, you can add ids and classes to the HTML partials in `/layouts/partials`.
|
Want to go even more in-depth? You can add custom CSS styling and change existing colours through editing `assets/styles/custom.scss`. If you'd like to target specific parts of the site, you can add ids and classes to the HTML partials in `/layouts/partials`.
|
||||||
|
|
||||||
### Partials
|
### Partials
|
||||||
Partials are what dictate what actually gets rendered to the page. Want to change how pages are styled and structured? You can edit the appropriate layout in `/layouts`.
|
Partials are what dictate what actually gets rendered to the page. Want to change how pages are styled and structured? You can edit the appropriate layout in `/layouts`.
|
||||||
@@ -46,3 +47,21 @@ For example, the structure of the home page can be edited through `/layouts/inde
|
|||||||
More info about partials on [Hugo's website.](https://gohugo.io/templates/partials/)
|
More info about partials on [Hugo's website.](https://gohugo.io/templates/partials/)
|
||||||
|
|
||||||
Still having problems? Checkout our [FAQ and Troubleshooting guide](notes/troubleshooting.md).
|
Still having problems? Checkout our [FAQ and Troubleshooting guide](notes/troubleshooting.md).
|
||||||
|
|
||||||
|
## Multilingual
|
||||||
|
[CJK + Latex Support (测试)](notes/CJK%20+%20Latex%20Support%20(测试).md) comes out of the box with Quartz.
|
||||||
|
|
||||||
|
Want to support languages that read from right-to-left (like Arabic)? Hugo (and by proxy, Quartz) supports this natively.
|
||||||
|
|
||||||
|
Follow the steps [Hugo provides here](https://gohugo.io/content-management/multilingual/#configure-languages) and modify your `config.toml`
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
defaultContentLanguage = 'ar'
|
||||||
|
[languages]
|
||||||
|
[languages.ar]
|
||||||
|
languagedirection = 'rtl'
|
||||||
|
title = 'مدونتي'
|
||||||
|
weight = 1
|
||||||
|
```
|
||||||
|
|||||||
17
content/notes/custom Domain.md
Normal file
17
content/notes/custom Domain.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: "Custom Domain"
|
||||||
|
---
|
||||||
|
|
||||||
|
### Registrar
|
||||||
|
This step is only applicable if you are using a **custom domain**! If you are using a `<YOUR-USERNAME>.github.io` domain, you can skip this step.
|
||||||
|
|
||||||
|
For this last bit to take effect, you also need to create a CNAME record with the DNS provider you register your domain with (i.e. NameCheap, Google Domains).
|
||||||
|
|
||||||
|
GitHub has some [documentation on this](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site), but the tldr; is to
|
||||||
|
|
||||||
|
1. Go to your forked repository (`github.com/<YOUR-GITHUB-USERNAME>/quartz`) settings page and go to the Pages tab. Under "Custom domain", type your custom domain, then click **Save**.
|
||||||
|
2. Go to your DNS Provider and create a CNAME record that points from your domain to `<YOUR-GITHUB-USERNAME.github.io.` (yes, with the trailing period).
|
||||||
|
|
||||||
|
*Example Configuration for Quartz*
|
||||||
|
3. Wait 30 minutes to an hour for the network changes to kick in.
|
||||||
|
4. Done!
|
||||||
@@ -8,11 +8,11 @@ tags:
|
|||||||
Quartz runs on top of [Hugo](https://gohugo.io/) so all notes are written in [Markdown](https://www.markdownguide.org/getting-started/).
|
Quartz runs on top of [Hugo](https://gohugo.io/) so all notes are written in [Markdown](https://www.markdownguide.org/getting-started/).
|
||||||
|
|
||||||
### Obsidian
|
### Obsidian
|
||||||
I *strongly* recommend using [Obsidian](http://obsidian.md/) as a way to edit and grow your digital garden. It comes with a really nice editor and graphical interface to preview all of my local files.
|
I recommend using [Obsidian](http://obsidian.md/) as a way to edit and grow your digital garden. It comes with a really nice editor and graphical interface to preview all of your local files.
|
||||||
|
|
||||||
🔗 How to link your Obsidian Vault](notes/Obsidian.md)
|
This step is **highly recommended**.
|
||||||
|
|
||||||
Of course, all the files are in Markdown so you could just use your favourite text editor of choice.
|
🔗 [How to setup your Obsidian Vault to work with Quartz](notes/obsidian.md)
|
||||||
|
|
||||||
### Ignoring Files
|
### Ignoring Files
|
||||||
Only want to publish a subset of all of your notes? Don't worry, Quartz makes this a simple two-step process.
|
Only want to publish a subset of all of your notes? Don't worry, Quartz makes this a simple two-step process.
|
||||||
@@ -24,7 +24,7 @@ Here's a rough overview of what's what.
|
|||||||
|
|
||||||
**All content in your garden can found in the `/content` folder.** To make edits, you can open any of the files and make changes directly and save it. You can organize content into any folder you'd like.
|
**All content in your garden can found in the `/content` folder.** To make edits, you can open any of the files and make changes directly and save it. You can organize content into any folder you'd like.
|
||||||
|
|
||||||
**To edit the main home page, open `/content/_index.md`.** This is the home page which is slightly special. You don't need front matter here!
|
**To edit the main home page, open `/content/_index.md`.*
|
||||||
|
|
||||||
To create a link between notes in your garden, just create a normal link using Markdown pointing to the document in question. Please note that **all links should be relative to the root `/content` path**.
|
To create a link between notes in your garden, just create a normal link using Markdown pointing to the document in question. Please note that **all links should be relative to the root `/content` path**.
|
||||||
|
|
||||||
@@ -33,19 +33,29 @@ For example, I want to link this current document to `notes/config.md`.
|
|||||||
[A link to the config page](notes/config.md)
|
[A link to the config page](notes/config.md)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Similarly, you can put local images anywhere in the `/content` folder.
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
Example image (source is in content/notes/images/example.png)
|
||||||
|

|
||||||
|
```
|
||||||
|
|
||||||
### Front Matter
|
### Front Matter
|
||||||
Hugo is picky when it comes to metadata for files. Make sure that your title is double-quoted and that you have a title defined at the top of your file like so:
|
Hugo is picky when it comes to metadata for files. Make sure that your title is double-quoted and that you have a title defined at the top of your file like so. You can also add tags here as well.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
---
|
---
|
||||||
title: "Example Title"
|
title: "Example Title"
|
||||||
|
tags:
|
||||||
|
- example-tag
|
||||||
|
disableToc: true # do not show a table of contents on this page if enabled
|
||||||
---
|
---
|
||||||
|
|
||||||
Rest of your content here...
|
Rest of your content here...
|
||||||
```
|
```
|
||||||
|
|
||||||
## Previewing Changes
|
## Previewing Changes
|
||||||
This step is purely optional and mostly for those who want to see the published version of their digital garden locally before opening it up to the internet. This is *highly recommended*.
|
This step is purely optional and mostly for those who want to see the published version of their digital garden locally before opening it up to the internet. This is *highly recommended* but not required.
|
||||||
|
|
||||||
👀 [Preview Quartz Changes](notes/preview%20changes.md)
|
👀 [Preview Quartz Changes](notes/preview%20changes.md)
|
||||||
|
|
||||||
|
|||||||
@@ -5,24 +5,24 @@ tags:
|
|||||||
---
|
---
|
||||||
|
|
||||||
## GitHub Pages
|
## GitHub Pages
|
||||||
Quartz is designed to be effortless to deploy. If you forked and cloned Quartz directly from the repository, everything should already be good to go! You can head to `<YOUR-GITHUB-USERNAME.github.io/quartz` to see it live.
|
Quartz is designed to be effortless to deploy. If you forked and cloned Quartz directly from the repository, everything should already be good to go! Follow the steps below.
|
||||||
|
|
||||||
### Enable GitHub Actions
|
### Enable GitHub Actions
|
||||||
By default, GitHub disables workflows from running automatically on Forked Repostories. Head to the 'Actions' tab of your forked repository and Enable Workflows to setup deploying your Quartz site!
|
By default, GitHub disables workflows from running automatically on Forked Repostories. Head to the 'Actions' tab of your forked repository and Enable Workflows to setup deploying your Quartz site!
|
||||||
|
|
||||||
*Enable GitHub Actions*
|
*Enable GitHub Actions*
|
||||||
|
|
||||||
### Enable GitHub Pages
|
### Enable GitHub Pages
|
||||||
|
|
||||||
Head to the 'Settings' tab of your forked repository and go to the 'Pages' tab.
|
Head to the 'Settings' tab of your forked repository and go to the 'Pages' tab.
|
||||||
|
|
||||||
1. Set the source to deploy from `master` using `/ (root)`
|
1. (IMPORTANT) Set the source to deploy from `master` (and not `hugo`) using `/ (root)`
|
||||||
2. Set a custom domain here if you have one!
|
2. Set a custom domain here if you have one!
|
||||||
|
|
||||||
*Enable GitHub Pages*
|
*Enable GitHub Pages*
|
||||||
|
|
||||||
### Pushing Changes
|
### Pushing Changes
|
||||||
To see your changes on the internet, we need to push it them to GitHub. Quartz is essentially a `git` repository so updating it is the same workflow as you would follow as normal.
|
To see your changes on the internet, we need to push it them to GitHub. Quartz is a `git` repository so updating it is the same workflow as you would follow as if it were just a regular software project.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Navigate to Quartz folder
|
# Navigate to Quartz folder
|
||||||
@@ -36,10 +36,14 @@ git commit -m "message describing changes"
|
|||||||
git push origin hugo
|
git push origin hugo
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note: we specifically push to the `hugo` branch here. Our GitHub action automatically runs everytime a push to is detected to that branch and then updates the `master` branch for redeployment.
|
||||||
|
|
||||||
### Setting up the Site
|
### Setting up the Site
|
||||||
Now let's get this site up and running. Never hosted a site before? No problem. Have a fancy custom domain you already own or want to subdomain your Quartz? That's easy too.
|
Now let's get this site up and running. Never hosted a site before? No problem. Have a fancy custom domain you already own or want to subdomain your Quartz? That's easy too.
|
||||||
|
|
||||||
Here, we take advantage of GitHub's free page hosting to deploy our site. Change `baseURL` in `/config.toml`. If you don't have a custom domain to use, you can use `<YOUR-USERNAME>.github.io` (which GitHub gives to you for free!) as your domain.
|
Here, we take advantage of GitHub's free page hosting to deploy our site. Change `baseURL` in `/config.toml`.
|
||||||
|
|
||||||
|
Make sure that your `baseURL` has a trailing `/`!
|
||||||
|
|
||||||
[Reference `config.toml` here](https://github.com/jackyzha0/quartz/blob/hugo/config.toml)
|
[Reference `config.toml` here](https://github.com/jackyzha0/quartz/blob/hugo/config.toml)
|
||||||
|
|
||||||
@@ -47,7 +51,7 @@ Here, we take advantage of GitHub's free page hosting to deploy our site. Change
|
|||||||
baseURL = "https://<YOUR-DOMAIN>/"
|
baseURL = "https://<YOUR-DOMAIN>/"
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are using this under a subdomain (e.g. `<YOUR-GITHUB-USERNAME>.github.io/quartz`), include the trailing path.
|
If you are using this under a subdomain (e.g. `<YOUR-GITHUB-USERNAME>.github.io/quartz`), include the trailing `/`.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
baseURL = "https://<YOUR-GITHUB-USERNAME>.github.io/quartz/"
|
baseURL = "https://<YOUR-GITHUB-USERNAME>.github.io/quartz/"
|
||||||
@@ -55,6 +59,8 @@ baseURL = "https://<YOUR-GITHUB-USERNAME>.github.io/quartz/"
|
|||||||
|
|
||||||
Change `cname` in `/.github/workflows/deploy.yaml`. Again, if you don't have a custom domain to use, you can use `<YOUR-USERNAME>.github.io`.
|
Change `cname` in `/.github/workflows/deploy.yaml`. Again, if you don't have a custom domain to use, you can use `<YOUR-USERNAME>.github.io`.
|
||||||
|
|
||||||
|
Please note that the `cname` field should *not* have any path `e.g. end with /quartz` or have a trailing `/`.
|
||||||
|
|
||||||
[Reference `deploy.yaml` here](https://github.com/jackyzha0/quartz/blob/hugo/.github/workflows/deploy.yaml)
|
[Reference `deploy.yaml` here](https://github.com/jackyzha0/quartz/blob/hugo/.github/workflows/deploy.yaml)
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -67,22 +73,7 @@ Change `cname` in `/.github/workflows/deploy.yaml`. Again, if you don't have a c
|
|||||||
cname: <YOUR-DOMAIN>
|
cname: <YOUR-DOMAIN>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Registrar
|
Have a custom domain? [Learn how to set it up with Quartz ](notes/custom%20Domain.md).
|
||||||
This step is only applicable if you are using a **custom domain**! If you are using `<YOUR-USERNAME>.github.io`, you can skip this step.
|
|
||||||
|
|
||||||
For this last bit to take effect, you also need to create a CNAME record with the DNS provider you register your domain with (i.e. NameCheap, Google Domains).
|
|
||||||
|
|
||||||
GitHub has some [documentation on this](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site), but the tldr; is to
|
|
||||||
|
|
||||||
1. Go to your forked repository (`github.com/<YOUR-GITHUB-USERNAME>/quartz`) settings page and go to the Pages tab. Under "Custom domain", type your custom domain, then click **Save**.
|
|
||||||
2. Go to your DNS Provider and create a CNAME record that points from your domain to `<YOUR-GITHUB-USERNAME.github.io.` (yes, with the trailing period).
|
|
||||||
|
|
||||||
*Example Configuration for Quartz*
|
|
||||||
3. Wait 30 minutes to an hour for the network changes to kick in.
|
|
||||||
4. Done!
|
|
||||||
|
|
||||||
## External Hosting
|
|
||||||
Don't want to use GitHub Pages? Hugo builds everything for you! Everything is a packaged set of static files ready to deploy in `/public`. You can then upload this folder to a cloud provider to deploy. Alternatively, most providers also give users the option to link a GitHub repository and a folder to deploy. When doing this, ensure you select `/public` folder under the `master` branch.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -8,15 +8,16 @@ tags:
|
|||||||
Obsidian is the preferred way to use Quartz. You can either create a new Obsidian Vault or link one that your already have.
|
Obsidian is the preferred way to use Quartz. You can either create a new Obsidian Vault or link one that your already have.
|
||||||
|
|
||||||
### New Vault
|
### New Vault
|
||||||
If you don't have an existing Vault, [download Obsidian](https://obsidian.md/) and create a new Vault in the `/content` folder that you created and cloned during the [setup](notes/setup.md).
|
If you don't have an existing Vault, [download Obsidian](https://obsidian.md/) and create a new Vault in the `/content` folder that you created and cloned during the [setup](notes/setup.md) step.
|
||||||
|
|
||||||
### Linking an existing Vault
|
### Linking an existing Vault
|
||||||
The easiest way to use an existing Vault is to copy all of our files (directory and hierarchies intact) into the `/content` folder.
|
The easiest way to use an existing Vault is to copy all of your files (directory and hierarchies intact) into the `/content` folder.
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
Great, now that you have your Obsidian linked to your Quartz, let's fix some settings so that they play well.
|
Great, now that you have your Obsidian linked to your Quartz, let's fix some settings so that they play well.
|
||||||
|
|
||||||
Under Options > Files and Links, set the New link format to always be Absolute Path in Vault and disabled WikiLinks so Obsidian generates regular Markdown links.
|
1. Under Options > Files and Links, set the New link format to always be Absolute Path in Vault.
|
||||||
|
2. Go to Settings > Files & Links > Turn "on" automatically update internal links.
|
||||||
|
|
||||||
*Obsidian Settings*
|
*Obsidian Settings*
|
||||||
|
|
||||||
@@ -25,4 +26,4 @@ Inserting front matter everytime you want to create a new Note gets annoying rea
|
|||||||
|
|
||||||
**If you decide to overwrite the `/content` folder completely, don't remove the `/content/templates` folder!**
|
**If you decide to overwrite the `/content` folder completely, don't remove the `/content/templates` folder!**
|
||||||
|
|
||||||
Head over to Options > Core Plugins and enable the Templates plugin. Then go to Options > Hotkeys and set a hotkey for 'Insert Template'. That way, when you create a new note, you can just press the hotkey for a new template and be ready to go!
|
Head over to Options > Core Plugins and enable the Templates plugin. Then go to Options > Hotkeys and set a hotkey for 'Insert Template' (I recomment `[cmd]+T`). That way, when you create a new note, you can just press the hotkey for a new template and be ready to go!
|
||||||
@@ -4,24 +4,28 @@ title: "Preview Changes"
|
|||||||
|
|
||||||
If you'd like to preview what your Quartz site looks like before deploying it to the internet, here's exactly how to do that!
|
If you'd like to preview what your Quartz site looks like before deploying it to the internet, here's exactly how to do that!
|
||||||
|
|
||||||
|
Note that both of these steps need to be completed.
|
||||||
|
|
||||||
## Install `hugo-obsidian`
|
## Install `hugo-obsidian`
|
||||||
This step will generate the list of backlinks for Hugo to parse. Ensure you have [Go](https://golang.org/doc/install) (>= 1.16) installed.
|
This step will generate the list of backlinks for Hugo to parse. Ensure you have [Go](https://golang.org/doc/install) (>= 1.16) installed.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Install and link `hugo-obsidian` locally
|
# Install and link `hugo-obsidian` locally
|
||||||
$ go install github.com/jackyzha0/hugo-obsidian
|
$ go install github.com/jackyzha0/hugo-obsidian@latest
|
||||||
|
|
||||||
# Navigate to your local Quartz folder
|
# Navigate to your local Quartz folder
|
||||||
$ cd <location-of-your-local-quartz>
|
$ cd <location-of-your-local-quartz>
|
||||||
|
|
||||||
# Scrape all links in your Quartz folder and generate info for Quartz
|
# Scrape all links in your Quartz folder and generate info for Quartz
|
||||||
$ hugo-obsidian -input=content -output=data -index=true
|
$ hugo-obsidian -input=content -output=assets/indices -index -root=.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you are running into an error saying that `command not found: hugo-obsidian`, make sure you set your `GOPATH` correctly! This will allow your terminal to correctly recognize hugo-obsidian as an executable.
|
||||||
|
|
||||||
Afterwards, start the Hugo server as shown above and your local backlinks and interactive graph should be populated!
|
Afterwards, start the Hugo server as shown above and your local backlinks and interactive graph should be populated!
|
||||||
|
|
||||||
## Installing Hugo
|
## Installing Hugo
|
||||||
Hugo is the static site generator that powers Quartz. If you'd like to preview your site locally, [install Hugo](https://gohugo.io/getting-started/installing/).
|
Hugo is the static site generator that powers Quartz. [Install Hugo with "extended" Sass/SCSS version](https://gohugo.io/getting-started/installing/) first. Then,
|
||||||
|
|
||||||
```
|
```
|
||||||
# Navigate to your local Quartz folder
|
# Navigate to your local Quartz folder
|
||||||
|
|||||||
@@ -29,3 +29,15 @@ Great! Now you have everything you need to start editing and growing your digita
|
|||||||
✏️ [Editing Notes in Quartz](notes/editing.md)
|
✏️ [Editing Notes in Quartz](notes/editing.md)
|
||||||
|
|
||||||
Having problems? Checkout our [FAQ and Troubleshooting guide](notes/troubleshooting.md).
|
Having problems? Checkout our [FAQ and Troubleshooting guide](notes/troubleshooting.md).
|
||||||
|
|
||||||
|
## Updating
|
||||||
|
Haven't updated Quartz in a while and want all the cool new optimizations?
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# add Quartz as a remote host
|
||||||
|
git remote add upstream git@github.com:jackyzha0/quartz.git
|
||||||
|
|
||||||
|
# index and fetch changes
|
||||||
|
git fetch upstream
|
||||||
|
git checkout upstream/hugo -- layouts .github Makefile assets config.toml data layouts static
|
||||||
|
```
|
||||||
@@ -12,5 +12,7 @@ Want to see what Quartz can do? Here are some cool community gardens :)
|
|||||||
- [Chloe's Garden](https://garden.chloeabrasada.online/)
|
- [Chloe's Garden](https://garden.chloeabrasada.online/)
|
||||||
- [SlRvb's Site](https://slrvb.github.io/Site/)
|
- [SlRvb's Site](https://slrvb.github.io/Site/)
|
||||||
- [Course notes for Information Technology Advanced Theory](https://a2itnotes.github.io/quartz/)
|
- [Course notes for Information Technology Advanced Theory](https://a2itnotes.github.io/quartz/)
|
||||||
|
- [Brandon Boswell's Garden](https://brandonkboswell.com)
|
||||||
|
- [Siyang's Courtyard](https://siyangsun.github.io/courtyard/)
|
||||||
|
|
||||||
If you want to see your own on here, submit a [Pull Request adding yourself to this file](https://github.com/jackyzha0/quartz/blob/hugo/content/moc/showcase.md)!
|
If you want to see your own on here, submit a [Pull Request adding yourself to this file](https://github.com/jackyzha0/quartz/blob/hugo/content/notes/showcase.md)!
|
||||||
@@ -2,7 +2,21 @@
|
|||||||
title: "Troubleshooting and FAQ"
|
title: "Troubleshooting and FAQ"
|
||||||
---
|
---
|
||||||
|
|
||||||
## Common Pitfalls
|
Still having trouble? Here are a list of common questions and problems people encounter when installing Quartz.
|
||||||
|
|
||||||
|
While you're here, join our [Discord](https://discord.gg/cRFFHYye7t) :)
|
||||||
|
|
||||||
|
### Does Quartz have Latex support?
|
||||||
|
Yes! See [CJK + Latex Support (测试)](notes/CJK%20+%20Latex%20Support%20(测试).md) for a brief demo.
|
||||||
|
|
||||||
|
### Can I use \<Obsidian Plugin\> in Quartz?
|
||||||
|
Unless it produces direct Markdown output in the file, no. There currently is no way to bundle plugin code with Quartz.
|
||||||
|
|
||||||
|
The easiest way would be to add your own HTML partial that supports the functionality you are looking for.
|
||||||
|
|
||||||
|
### My GitHub pages is just showing the README and not Quartz
|
||||||
|
Make sure you set the source to deploy from `master` (and not `hugo`) using `/ (root)`! See more in the [hosting](/notes/hosting) guide
|
||||||
|
|
||||||
### Some of my pages have 'January 1, 0001' as the last modified date
|
### Some of my pages have 'January 1, 0001' as the last modified date
|
||||||
This is a problem caused by `git` treating files as case-insensitive by default and some of your posts probably have capitalized file names. You can turn this off in your Quartz by running this command.
|
This is a problem caused by `git` treating files as case-insensitive by default and some of your posts probably have capitalized file names. You can turn this off in your Quartz by running this command.
|
||||||
|
|
||||||
@@ -20,9 +34,6 @@ Yes! Quartz makes selective publishing really easy. Heres a guide on [excluding
|
|||||||
### Can I host this myself and not on GitHub Pages?
|
### Can I host this myself and not on GitHub Pages?
|
||||||
Yes! All built files can be found under `/public` in the `master` branch. More details under [hosting](notes/hosting.md).
|
Yes! All built files can be found under `/public` in the `master` branch. More details under [hosting](notes/hosting.md).
|
||||||
|
|
||||||
### Do I need a website already?
|
|
||||||
No! Setting up Quartz means you set up a site too :)
|
|
||||||
|
|
||||||
### `command not found: hugo-obsidian`
|
### `command not found: hugo-obsidian`
|
||||||
Make sure you set your `GOPATH` correctly! This will allow your terminal to correctly recognize `hugo-obsidian` as an executable.
|
Make sure you set your `GOPATH` correctly! This will allow your terminal to correctly recognize `hugo-obsidian` as an executable.
|
||||||
|
|
||||||
@@ -36,7 +47,7 @@ source ~/.bash_profile
|
|||||||
```
|
```
|
||||||
|
|
||||||
### How come my notes aren't being rendered?
|
### How come my notes aren't being rendered?
|
||||||
You probably forgot to include front matter in your Markdown files. You can either setup [Obsidian](notes/Obsidian.md) to do this for you or you need to manually define it. More details in [the 'how to edit' guide](notes/editing.md).
|
You probably forgot to include front matter in your Markdown files. You can either setup [Obsidian](notes/obsidian.md) to do this for you or you need to manually define it. More details in [the 'how to edit' guide](notes/editing.md).
|
||||||
|
|
||||||
### My custom domain isn't working!
|
### My custom domain isn't working!
|
||||||
Walk through the steps in [the hosting guide](notes/hosting.md) again. Make sure you wait 30 min to 1 hour for changes to take effect.
|
Walk through the steps in [the hosting guide](notes/hosting.md) again. Make sure you wait 30 min to 1 hour for changes to take effect.
|
||||||
@@ -51,7 +62,7 @@ To edit the main home page, open `/content/_index.md`.
|
|||||||
You can change the theme by editing `assets/custom.scss`. More details on customization and themeing can be found in the [customization guide](notes/config.md).
|
You can change the theme by editing `assets/custom.scss`. More details on customization and themeing can be found in the [customization guide](notes/config.md).
|
||||||
|
|
||||||
### How do I add images?
|
### How do I add images?
|
||||||
You can put images anywhere in the `/content` folder. The only caveat is that you should reference them in your Markdown by prefixing it with a `/`.
|
You can put images anywhere in the `/content` folder.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
Example image (source is in content/notes/images/example.png)
|
Example image (source is in content/notes/images/example.png)
|
||||||
@@ -59,7 +70,7 @@ Example image (source is in content/notes/images/example.png)
|
|||||||
```
|
```
|
||||||
|
|
||||||
### My Interactive Graph and Backlinks aren't up to date
|
### My Interactive Graph and Backlinks aren't up to date
|
||||||
By default, the `linkIndex.yaml` (which Quartz needs to generate the Interactive Graph and Backlinks) are not regenerated locally. To set that up, see the guide on [local editing](notes/editing.md)
|
By default, the `linkIndex.json` (which Quartz needs to generate the Interactive Graph and Backlinks) are not regenerated locally. To set that up, see the guide on [local editing](notes/editing.md)
|
||||||
|
|
||||||
### Can I use React/Vue/some other framework?
|
### Can I use React/Vue/some other framework?
|
||||||
Not out of the box. You could probably make it work by editing `/layouts/_default/single.html` but that's not what Quartz is designed to work with. 99% of things you are trying to do with those frameworks you can accomplish perfectly fine using just vanilla HTML/CSS/JS.
|
Not out of the box. You could probably make it work by editing `/layouts/_default/single.html` but that's not what Quartz is designed to work with. 99% of things you are trying to do with those frameworks you can accomplish perfectly fine using just vanilla HTML/CSS/JS.
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
name: Jacky Zhao
|
name: Jacky Zhao
|
||||||
enableToc: true
|
enableToc: true
|
||||||
enableLinkPreview: true
|
enableLinkPreview: true
|
||||||
|
enableLatex: true
|
||||||
description:
|
description:
|
||||||
Here is the page description. This is an example Quartz site that details installation,
|
Host your second brain and digital garden for free. Quartz features extremely fast full-text search,
|
||||||
setup, customization, and troubleshooting for Quartz itself.
|
Wikilink support, backlinks, local graph, tags, and link previews.
|
||||||
page_title:
|
page_title:
|
||||||
"🪴 Quartz 3"
|
"🪴 Quartz 3.2"
|
||||||
links:
|
links:
|
||||||
- link_name: Twitter
|
- link_name: Twitter
|
||||||
link: https://twitter.com/_jzhao
|
link: https://twitter.com/_jzhao
|
||||||
|
|||||||
8
layouts/_default/_markup/render-image.html
Normal file
8
layouts/_default/_markup/render-image.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{{$src := .Destination | safeURL }}
|
||||||
|
{{$external := strings.HasPrefix $src "http" }}
|
||||||
|
{{- if $external -}}
|
||||||
|
<img src="{{ $src }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} />
|
||||||
|
{{- else -}}
|
||||||
|
{{$fixedUrl := (cond (hasPrefix $src "/") $src (print "/" $src)) | urlize}}
|
||||||
|
<img src="{{ $fixedUrl }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} />
|
||||||
|
{{- end -}}
|
||||||
@@ -1,9 +1,16 @@
|
|||||||
{{$trimmed := strings.TrimSuffix ".md" (.Destination | safeURL)}}
|
{{$trimmed := strings.TrimSuffix ".md" (.Destination | safeURL)}}
|
||||||
{{$trimmed = replace $trimmed "%20" "-" }}
|
{{$dashedurl := replace $trimmed "%20" "-" }}
|
||||||
{{$external := strings.HasPrefix $trimmed "http" }}
|
{{$external := strings.HasPrefix $dashedurl "http" }}
|
||||||
{{- if $external -}}
|
{{- if $external -}}
|
||||||
<a href="{{ $trimmed }}" rel="noopener">{{ .Text | safeHTML }}</a>
|
<a href="{{ $dashedurl }}" rel="noopener">{{ .Text | safeHTML }}</a>
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{$fixedUrl := (cond (hasPrefix $trimmed "/") $trimmed (print "/" $trimmed)) | urlize}}
|
{{$spacedurl := replace $trimmed "%20" " " }}
|
||||||
<a href="{{$fixedUrl}}" rel="noopener" class="internal-link" data-src="{{$fixedUrl}}">{{ .Text | safeHTML }}</a>
|
{{$fixedUrl := (cond (hasPrefix $spacedurl "/") $spacedurl (print "/" $spacedurl)) | urlize}}
|
||||||
|
{{$nonexistent := eq (.Page.GetPage $spacedurl).RelPermalink ""}}
|
||||||
|
{{$rooted := default $spacedurl (strings.TrimRight "/" (.Page.GetPage $spacedurl).RelPermalink) }}
|
||||||
|
<a
|
||||||
|
{{if not $nonexistent}}href="{{$rooted}}"{{end}}
|
||||||
|
rel="noopener" class="internal-link{{if $nonexistent}} broken{{end}}"
|
||||||
|
data-src="{{$rooted}}">{{ .Text | safeHTML }}
|
||||||
|
</a>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
</article>
|
</article>
|
||||||
{{partial "contact.html" .}}
|
{{partial "contact.html" .}}
|
||||||
</div>
|
</div>
|
||||||
|
{{partial "popover.html" .}}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="{{ .Lang }}">
|
||||||
{{ partial "head.html" . }}
|
{{ partial "head.html" . }}
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@@ -22,16 +22,16 @@
|
|||||||
<li><a href="{{ .Permalink }}">{{ .LinkTitle | humanize }}</a></li>
|
<li><a href="{{ .Permalink }}">{{ .LinkTitle | humanize }}</a></li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
{{if $.Site.Data.config.enableToc}}
|
{{ if (and $.Site.Data.config.enableToc (not (.Params.disableToc))) }}
|
||||||
<aside class="mainTOC">
|
<aside class="mainTOC">
|
||||||
<h3>Table of Contents</h3>
|
<h3>Table of Contents</h3>
|
||||||
{{ .TableOfContents }}
|
{{ .TableOfContents }}
|
||||||
</aside>
|
</aside>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{.Content}}
|
{{partial "textprocessing.html" . }}
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
{{partial "footer.html" .}}
|
{{partial "footer.html" .}}
|
||||||
|
{{partial "popover.html" .}}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
</article>
|
</article>
|
||||||
{{partial "contact.html" .}}
|
{{partial "contact.html" .}}
|
||||||
</div>
|
</div>
|
||||||
|
{{partial "popover.html" .}}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
</article>
|
</article>
|
||||||
{{partial "contact.html" .}}
|
{{partial "contact.html" .}}
|
||||||
</div>
|
</div>
|
||||||
|
{{partial "popover.html" .}}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="{{ .Lang }}">
|
||||||
{{ partial "head.html" . }}
|
{{ partial "head.html" . }}
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@@ -13,15 +13,16 @@
|
|||||||
{{partial "darkmode.html" .}}
|
{{partial "darkmode.html" .}}
|
||||||
</header>
|
</header>
|
||||||
<article>
|
<article>
|
||||||
{{if $.Site.Data.config.enableToc}}
|
{{ if (and $.Site.Data.config.enableToc (not (.Params.disableToc))) }}
|
||||||
<aside class="mainTOC">
|
<aside class="mainTOC">
|
||||||
<h3>Table of Contents</h3>
|
<h3>Table of Contents</h3>
|
||||||
{{ .TableOfContents }}
|
{{ .TableOfContents }}
|
||||||
</aside>
|
</aside>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{- .Content -}}
|
{{partial "textprocessing.html" . }}
|
||||||
</article>
|
</article>
|
||||||
{{partial "footer.html" .}}
|
{{partial "footer.html" .}}
|
||||||
|
{{partial "popover.html" .}}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -3,14 +3,18 @@
|
|||||||
{{$url := urls.Parse .Site.BaseURL }}
|
{{$url := urls.Parse .Site.BaseURL }}
|
||||||
{{$host := strings.TrimRight "/" $url.Path }}
|
{{$host := strings.TrimRight "/" $url.Path }}
|
||||||
{{$curPage := strings.TrimPrefix $host (strings.TrimRight "/" .Page.RelPermalink)}}
|
{{$curPage := strings.TrimPrefix $host (strings.TrimRight "/" .Page.RelPermalink)}}
|
||||||
{{$inbound := index $.Site.Data.linkIndex.index.backlinks $curPage}}
|
{{$linkIndex := getJSON "/assets/indices/linkIndex.json"}}
|
||||||
{{$contentTable := $.Site.Data.contentIndex}}
|
{{$inbound := index $linkIndex.index.backlinks $curPage}}
|
||||||
|
{{$contentTable := getJSON "/assets/indices/contentIndex.json"}}
|
||||||
{{if $inbound}}
|
{{if $inbound}}
|
||||||
{{$cleanedInbound := apply (apply $inbound "index" "." "source") "replace" "." " " "-"}}
|
{{$cleanedInbound := apply (apply $inbound "index" "." "source") "replace" "." " " "-"}}
|
||||||
{{- range $cleanedInbound | uniq -}}
|
{{- range $cleanedInbound | uniq -}}
|
||||||
|
{{$l := printf "%s%s" $host .}}
|
||||||
|
{{with (index $contentTable .)}}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{.}}">{{index (index $contentTable .) "title"}}</a>
|
<a href="{{$l}}">{{index (index . "title")}}</a>
|
||||||
</li>
|
</li>
|
||||||
|
{{end}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
<div id="contact_buttons">
|
<div id="contact_buttons">
|
||||||
<footer>
|
<footer>
|
||||||
<p>Made by {{ $.Site.Data.config.name }} using <a href="https://github.com/jackyzha0/quartz">Quartz</a>, © {{ dateFormat "2006" now }}</p>
|
<p>Made by {{ $.Site.Data.config.name }} using <a href="https://github.com/jackyzha0/quartz">Quartz</a>, © {{ dateFormat "2006" now }}</p>
|
||||||
|
<ul>
|
||||||
{{ if not .IsHome }}
|
{{ if not .IsHome }}
|
||||||
<a href="/">Home</a>
|
<li><a href="/">Home</a></li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{- range $.Site.Data.config.links -}}
|
{{- range $.Site.Data.config.links -}}
|
||||||
<a href="{{.link}}">{{.link_name}}</a>
|
<li><a href="{{.link}}">{{.link_name}}</a></li>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
</ul>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/d3@6"></script>
|
<script src="https://cdn.jsdelivr.net/npm/d3@6.7.0/dist/d3.min.js" integrity="sha256-+7jaYCp29O1JusNWHaYtgUn6EhuP0VaFuswhNV06MyI=" crossorigin="anonymous"></script>
|
||||||
<h3>Interactive Graph</h3>
|
<h3>Interactive Graph</h3>
|
||||||
<div id="graph-container"></div>
|
<div id="graph-container"></div>
|
||||||
<style>
|
<style>
|
||||||
@@ -10,227 +10,16 @@
|
|||||||
--g-link-active: #5a7282;
|
--g-link-active: #5a7282;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
{{ $js := resources.Get "js/graph.js" | resources.Fingerprint "md5" }}
|
||||||
|
<script src="{{ $js.Permalink }}"></script>
|
||||||
<script>
|
<script>
|
||||||
const curPage = {{ strings.TrimRight "/" .Page.RelPermalink }}
|
drawGraph(
|
||||||
const pathColors = {{$.Site.Data.graphConfig.paths}}
|
{{strings.TrimRight "/" .Page.Permalink}},
|
||||||
let depth = {{$.Site.Data.graphConfig.depth}}
|
{{strings.TrimRight "/" .Site.BaseURL}},
|
||||||
|
{{$.Site.Data.graphConfig.paths}},
|
||||||
const parseIdsFromLinks = (links) => [...(new Set(links.flatMap(link => ([link.source, link.target]))))]
|
{{$.Site.Data.graphConfig.depth}},
|
||||||
|
{{$.Site.Data.graphConfig.enableDrag}},
|
||||||
const neighbours = new Set()
|
{{$.Site.Data.graphConfig.enableLegend}},
|
||||||
const wl = [curPage || "/", "__SENTINEL"]
|
{{$.Site.Data.graphConfig.enableZoom}}
|
||||||
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 enableDrag = {{$.Site.Data.graphConfig.enableDrag}}
|
|
||||||
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]);
|
|
||||||
|
|
||||||
// legend
|
|
||||||
const enableLegend = {{$.Site.Data.graphConfig.enableLegend}}
|
|
||||||
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 = {{.Site.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[decodeURI(d.id).replace(/[\s_]+/g, '-')]?.title || "Untitled")
|
|
||||||
.style("opacity", 0)
|
|
||||||
.style("pointer-events", "none")
|
|
||||||
.call(drag(simulation));
|
|
||||||
|
|
||||||
// set panning
|
|
||||||
const enableZoom = {{$.Site.Data.graphConfig.enableZoom}}
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -8,28 +8,39 @@
|
|||||||
|
|
||||||
<!-- CSS Stylesheets and Fonts -->
|
<!-- CSS Stylesheets and Fonts -->
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Source+Sans+Pro:wght@400;600;700&family=Fira+Code:wght@400;700&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Source+Sans+Pro:wght@400;600;700&family=Fira+Code:wght@400;700&display=swap" rel="stylesheet">
|
||||||
{{ $css := slice "custom.scss" "base.scss" "darkmode.scss" "syntax.scss"}}
|
{{$sass := resources.Match "styles/[!_]*.scss" }}
|
||||||
{{range $css}}
|
{{$css := slice }}
|
||||||
{{$sass := resources.Get . | resources.ToCSS }}
|
{{range $sass}}
|
||||||
{{with $sass | minify}}
|
{{$scss := . | resources.ToCSS (dict "outputStyle" "compressed") }}
|
||||||
<style>
|
{{$css = $css | append $scss}}
|
||||||
{{.Content | safeCSS}}
|
|
||||||
</style>
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{$finalCss := $css | resources.Concat "styles.css" | resources.Fingerprint "md5" | resources.Minify }}
|
||||||
|
<link href="{{$finalCss.Permalink}}" rel="stylesheet">
|
||||||
|
|
||||||
{{- with resources.Get "darkmode.js" | minify -}}
|
{{ $darkMode := resources.Get "js/darkmode.js" | resources.Fingerprint "md5" | resources.Minify }}
|
||||||
<script>
|
<script src="{{$darkMode.Permalink}}"></script>
|
||||||
{{.Content | safeJS }}
|
{{partial "katex.html" .}}
|
||||||
</script>
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
<!-- Preload page vars -->
|
<!-- Preload page vars -->
|
||||||
|
{{$linkIndex := resources.Get "indices/linkIndex.json" | resources.Fingerprint "md5" | resources.Minify | }}
|
||||||
|
{{$contentIndex := resources.Get "indices/contentIndex.json" | resources.Fingerprint "md5" | resources.Minify }}
|
||||||
<script>
|
<script>
|
||||||
const content = {{$.Site.Data.contentIndex}}
|
const BASE_URL = {{.Site.BaseURL}}
|
||||||
const index = {{$.Site.Data.linkIndex.index}}
|
const fetchData = Promise.all([
|
||||||
const links = {{$.Site.Data.linkIndex.links}}
|
fetch("{{ $linkIndex.Permalink }}")
|
||||||
|
.then(data => data.json())
|
||||||
|
.then(data => ({
|
||||||
|
index: data.index,
|
||||||
|
links: data.links,
|
||||||
|
})),
|
||||||
|
fetch("{{ $contentIndex.Permalink }}")
|
||||||
|
.then(data => data.json()),
|
||||||
|
])
|
||||||
|
.then(([{index, links}, content]) => ({
|
||||||
|
index,
|
||||||
|
links,
|
||||||
|
content,
|
||||||
|
}))
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
{{ template "_internal/google_analytics.html" . }}
|
{{ template "_internal/google_analytics.html" . }}
|
||||||
{{ partial "popover.html" .}}
|
|
||||||
|
|||||||
16
layouts/partials/katex.html
Normal file
16
layouts/partials/katex.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{{if $.Site.Data.config.enableLatex}}
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.css" integrity="sha384-R4558gYOUz8mP9YWpZJjofhk+zx0AS11p36HnD2ZKj/6JR5z27gSSULCNHIRReVs" crossorigin="anonymous">
|
||||||
|
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.js" integrity="sha384-z1fJDqw8ZApjGO3/unPWUPsIymfsJmyrDVWC8Tv/a1HeOtGmkwNd/7xUS0Xcnvsx" crossorigin="anonymous"></script>
|
||||||
|
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
|
renderMathInElement(document.body, {
|
||||||
|
delimiters: [
|
||||||
|
{left: '$$', right: '$$', display: true},
|
||||||
|
{left: '$', right: '$', display: false},
|
||||||
|
],
|
||||||
|
throwOnError : false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{{end}}
|
||||||
@@ -1,31 +1,7 @@
|
|||||||
{{if $.Site.Data.config.enableLinkPreview}}
|
{{if $.Site.Data.config.enableLinkPreview}}
|
||||||
|
{{ $js := resources.Get "js/popover.js" | resources.Fingerprint "md5" | resources.Minify }}
|
||||||
|
<script src="{{ $js.Permalink }}"></script>
|
||||||
<script>
|
<script>
|
||||||
function htmlToElement(html) {
|
initPopover({{strings.TrimRight "/" .Site.BaseURL }})
|
||||||
const template = document.createElement('template')
|
|
||||||
html = html.trim()
|
|
||||||
template.innerHTML = html
|
|
||||||
return template.content.firstChild
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
|
||||||
[...document.getElementsByClassName("internal-link")]
|
|
||||||
.forEach(li => {
|
|
||||||
const linkDest = content[li.dataset.src]
|
|
||||||
if (linkDest) {
|
|
||||||
const popoverElement = `<div class="popover">
|
|
||||||
<h3>${linkDest.title}</h3>
|
|
||||||
<p>${removeMarkdown(linkDest.content).split(" ", 15).join(" ")}...</p>
|
|
||||||
</div>`
|
|
||||||
const el = htmlToElement(popoverElement)
|
|
||||||
li.appendChild(el)
|
|
||||||
li.addEventListener("mouseover", () => {
|
|
||||||
el.classList.add("visible")
|
|
||||||
})
|
|
||||||
li.addEventListener("mouseout", () => {
|
|
||||||
el.classList.remove("visible")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
{{end}}
|
{{end}}
|
||||||
@@ -5,251 +5,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.7.2/dist/flexsearch.bundle.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/flexsearch@0.7.21/dist/flexsearch.bundle.js" integrity="sha256-i3A0NZGkhsKjVMzFxv3ksk0DZh3aXqu0l49Bbh0MdjE=" crossorigin="anonymous" defer></script>
|
||||||
<script>
|
{{ $js := resources.Get "js/search.js" | resources.Fingerprint "md5" | resources.Minify }}
|
||||||
// code from https://github.com/danestves/markdown-to-text
|
<script defer src="{{ $js.Permalink }}"></script>
|
||||||
const removeMarkdown = (
|
|
||||||
markdown,
|
|
||||||
options = {
|
|
||||||
listUnicodeChar: false,
|
|
||||||
stripListLeaders: true,
|
|
||||||
gfm: true,
|
|
||||||
useImgAltText: false,
|
|
||||||
preserveLinks: false,
|
|
||||||
}
|
|
||||||
) => {
|
|
||||||
let output = markdown || "";
|
|
||||||
output = output.replace(/^(-\s*?|\*\s*?|_\s*?){3,}\s*$/gm, "");
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (options.stripListLeaders) {
|
|
||||||
if (options.listUnicodeChar)
|
|
||||||
output = output.replace(
|
|
||||||
/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm,
|
|
||||||
options.listUnicodeChar + " $1"
|
|
||||||
);
|
|
||||||
else output = output.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm, "$1");
|
|
||||||
}
|
|
||||||
if (options.gfm) {
|
|
||||||
output = output
|
|
||||||
.replace(/\n={2,}/g, "\n")
|
|
||||||
.replace(/~{3}.*\n/g, "")
|
|
||||||
.replace(/~~/g, "")
|
|
||||||
.replace(/`{3}.*\n/g, "");
|
|
||||||
}
|
|
||||||
if (options.preserveLinks) {
|
|
||||||
output = output.replace(/\[(.*?)\][\[\(](.*?)[\]\)]/g, "$1 ($2)")
|
|
||||||
}
|
|
||||||
output = output
|
|
||||||
.replace(/<[^>]*>/g, "")
|
|
||||||
.replace(/^[=\-]{2,}\s*$/g, "")
|
|
||||||
.replace(/\[\^.+?\](\: .*?$)?/g, "")
|
|
||||||
.replace(/\s{0,2}\[.*?\]: .*?$/g, "")
|
|
||||||
.replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, options.useImgAltText ? "$1" : "")
|
|
||||||
.replace(/\[(.*?)\][\[\(].*?[\]\)]/g, "$1")
|
|
||||||
.replace(/^\s{0,3}>\s?/g, "")
|
|
||||||
.replace(/(^|\n)\s{0,3}>\s?/g, "\n\n")
|
|
||||||
.replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g, "")
|
|
||||||
.replace(
|
|
||||||
/^(\n)?\s{0,}#{1,6}\s+| {0,}(\n)?\s{0,}#{0,} {0,}(\n)?\s{0,}$/gm,
|
|
||||||
"$1$2$3"
|
|
||||||
)
|
|
||||||
.replace(/([\*_]{1,3})(\S.*?\S{0,1})\1/g, "$2")
|
|
||||||
.replace(/([\*_]{1,3})(\S.*?\S{0,1})\1/g, "$2")
|
|
||||||
.replace(/(`{3,})(.*?)\1/gm, "$2")
|
|
||||||
.replace(/`(.+?)`/g, "$1")
|
|
||||||
.replace(/\n{2,}/g, "\n\n");
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
return markdown;
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
const contentIndex = new FlexSearch.Document({
|
|
||||||
cache: true,
|
|
||||||
charset: "latin:extra",
|
|
||||||
optimize: true,
|
|
||||||
worker: true,
|
|
||||||
document: {
|
|
||||||
index: [{
|
|
||||||
field: "content",
|
|
||||||
tokenize: "strict",
|
|
||||||
context: {
|
|
||||||
resolution: 5,
|
|
||||||
depth: 3,
|
|
||||||
bidirectional: true
|
|
||||||
},
|
|
||||||
suggest: true,
|
|
||||||
}, {
|
|
||||||
field: "title",
|
|
||||||
tokenize: "forward",
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
for (const [key, value] of Object.entries(content)) {
|
|
||||||
contentIndex.add({
|
|
||||||
id: key,
|
|
||||||
title: value.title,
|
|
||||||
content: removeMarkdown(value.content),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const highlight = (content, term) => {
|
|
||||||
const highlightWindow = 20
|
|
||||||
const tokenizedTerm = term.split(/\s+/).filter(t => t !== "")
|
|
||||||
const splitText = content.split(/\s+/).filter(t => t !== "")
|
|
||||||
const includesCheck = (token) => tokenizedTerm.some(term => token.toLowerCase().startsWith(term.toLowerCase()))
|
|
||||||
|
|
||||||
const occurrencesIndices = splitText
|
|
||||||
.map(includesCheck)
|
|
||||||
|
|
||||||
// calculate best index
|
|
||||||
let bestSum = 0
|
|
||||||
let bestIndex = 0
|
|
||||||
for (let i = 0; i < Math.max(occurrencesIndices.length - highlightWindow, 0); i++) {
|
|
||||||
const window = occurrencesIndices.slice(i, i + highlightWindow)
|
|
||||||
const windowSum = window.reduce((total, cur) => total + cur, 0)
|
|
||||||
if (windowSum >= bestSum) {
|
|
||||||
bestSum = windowSum
|
|
||||||
bestIndex = i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const startIndex = Math.max(bestIndex - highlightWindow, 0)
|
|
||||||
const endIndex = Math.min(startIndex + 2 * highlightWindow, splitText.length)
|
|
||||||
const mappedText = splitText
|
|
||||||
.slice(startIndex, endIndex)
|
|
||||||
.map(token => {
|
|
||||||
if (includesCheck(token)) {
|
|
||||||
return `<span class="search-highlight">${token}</span>`
|
|
||||||
}
|
|
||||||
return token
|
|
||||||
})
|
|
||||||
.join(" ")
|
|
||||||
.replaceAll('</span> <span class="search-highlight">', " ")
|
|
||||||
return `${startIndex === 0 ? "" : "..."}${mappedText}${endIndex === splitText.length ? "" : "..."}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const resultToHTML = ({url, title, content, term}) => {
|
|
||||||
const text = removeMarkdown(content)
|
|
||||||
const resultTitle = highlight(title, term)
|
|
||||||
const resultText = highlight(text, term)
|
|
||||||
return `<button class="result-card" id="${url}">
|
|
||||||
<h3>${resultTitle}</h3>
|
|
||||||
<p>${resultText}</p>
|
|
||||||
</button>`
|
|
||||||
}
|
|
||||||
|
|
||||||
const redir = (id, term) => {
|
|
||||||
window.location.href = "{{.Site.BaseURL}}" + `${id}#:~:text=${encodeURIComponent(term)}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetch = id => ({
|
|
||||||
id,
|
|
||||||
url: id,
|
|
||||||
title: content[id].title,
|
|
||||||
content: content[id].content
|
|
||||||
})
|
|
||||||
|
|
||||||
const source = document.getElementById('search-bar')
|
|
||||||
const results = document.getElementById("results-container")
|
|
||||||
let term
|
|
||||||
source.addEventListener("keyup", (e) => {
|
|
||||||
if (e.key === "Enter") {
|
|
||||||
const anchor = document.getElementsByClassName("result-card")[0]
|
|
||||||
redir(anchor.id, term)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
source.addEventListener('input', (e) => {
|
|
||||||
term = e.target.value
|
|
||||||
contentIndex.search(term, [
|
|
||||||
{
|
|
||||||
field: "content",
|
|
||||||
limit: 10,
|
|
||||||
suggest: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: "title",
|
|
||||||
limit: 5,
|
|
||||||
}
|
|
||||||
]).then(searchResults => {
|
|
||||||
const getByField = field => {
|
|
||||||
const results = searchResults.filter(x => x.field === field)
|
|
||||||
if (results.length === 0) {
|
|
||||||
return []
|
|
||||||
} else {
|
|
||||||
return [...results[0].result]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const allIds = new Set([...getByField('title'), ...getByField('content')])
|
|
||||||
const finalResults = [...allIds].map(fetch)
|
|
||||||
|
|
||||||
// display
|
|
||||||
if (finalResults.length === 0) {
|
|
||||||
results.innerHTML = `<button class="result-card">
|
|
||||||
<h3>No results.</h3>
|
|
||||||
<p>Try another search term?</p>
|
|
||||||
</button>`
|
|
||||||
} else {
|
|
||||||
results.innerHTML = finalResults
|
|
||||||
.map(result => resultToHTML({
|
|
||||||
...result,
|
|
||||||
term,
|
|
||||||
}))
|
|
||||||
.join("\n")
|
|
||||||
const anchors = document.getElementsByClassName("result-card");
|
|
||||||
[...anchors].forEach(anchor => {
|
|
||||||
anchor.onclick = () => redir(anchor.id, term)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
const searchContainer = document.getElementById("search-container")
|
|
||||||
function openSearch() {
|
|
||||||
if (searchContainer.style.display === "none" || searchContainer.style.display === "") {
|
|
||||||
source.value = ""
|
|
||||||
results.innerHTML = ""
|
|
||||||
searchContainer.style.display = "block"
|
|
||||||
source.focus()
|
|
||||||
} else {
|
|
||||||
searchContainer.style.display = "none"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeSearch() {
|
|
||||||
searchContainer.style.display = "none"
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener('keydown', (event) => {
|
|
||||||
if (event.key === "/") {
|
|
||||||
event.preventDefault()
|
|
||||||
openSearch()
|
|
||||||
}
|
|
||||||
if (event.key === "Escape") {
|
|
||||||
event.preventDefault()
|
|
||||||
closeSearch()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
|
||||||
const searchButton = document.getElementById("search-icon")
|
|
||||||
searchButton.addEventListener('click', (evt) => {
|
|
||||||
openSearch()
|
|
||||||
})
|
|
||||||
searchButton.addEventListener('keydown', (evt) => {
|
|
||||||
openSearch()
|
|
||||||
})
|
|
||||||
searchContainer.addEventListener('click', (evt) => {
|
|
||||||
closeSearch()
|
|
||||||
})
|
|
||||||
document.getElementById("search-space").addEventListener('click', (evt) => {
|
|
||||||
evt.stopPropagation()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|||||||
31
layouts/partials/textprocessing.html
Normal file
31
layouts/partials/textprocessing.html
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{{ $content := .Content }}
|
||||||
|
{{ $page := .Page }}
|
||||||
|
|
||||||
|
{{/* Replace right arrow */}}
|
||||||
|
{{ $content = replace $content "->" "→" }}
|
||||||
|
|
||||||
|
{{/* Escape slashes for Latex to fix line breaks */}}
|
||||||
|
{{ $content = replaceRE "\\\\ *\n" "\\\\" $content }}
|
||||||
|
|
||||||
|
{{/* Wikilinks */}}
|
||||||
|
{{$wikilinks := $content | findRE "\\[\\[[^\\[\\]\\|]*(?:\\|[^\\[\\]]*)?\\]\\]" }}
|
||||||
|
{{range $wikilinks}}
|
||||||
|
{{$inner := . | strings.TrimPrefix "[[" | strings.TrimSuffix "]]" }}
|
||||||
|
{{$split := split $inner "|"}}
|
||||||
|
{{$path := index $split 0}}
|
||||||
|
{{$reference := split $path "#"}}
|
||||||
|
{{$title := index $reference 0}}
|
||||||
|
{{$block := default "" (index $reference 1)}}
|
||||||
|
{{$block = strings.TrimRight "/" (cond (eq $block "") $block (printf "#%s" $block))}}
|
||||||
|
{{$href := strings.TrimRight "/" ($page.GetPage $title).RelPermalink}}
|
||||||
|
{{$display := default $title (index $split 1)}}
|
||||||
|
{{if not $href}}
|
||||||
|
{{$link := printf "<a class=\"internal-link broken\">%s</a>" $display}}
|
||||||
|
{{ $content = replace $content . $link }}
|
||||||
|
{{else}}
|
||||||
|
{{$fullhref := printf "%s%s" $href $block }}
|
||||||
|
{{$link := printf "<a href=\"%s\" rel=\"noopener\" class=\"internal-link\" data-src=\"%s\">%s</a>" $fullhref $href $display}}
|
||||||
|
{{ $content = replace $content . $link }}
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
{{ $content | safeHTML }}
|
||||||
BIN
screenshot.png
Normal file
BIN
screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 923 KiB |
Reference in New Issue
Block a user