mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 05:14:06 -06:00
updated base quartz
This commit is contained in:
parent
4ba7f82592
commit
bf3e060a13
2
Makefile
2
Makefile
@ -4,12 +4,14 @@ help: ## Show all Makefile targets
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
update: ## Update Quartz to the latest version on Github
|
||||
go install github.com/jackyzha0/hugo-obsidian@latest
|
||||
@git remote show upstream || (echo "remote 'upstream' not present, setting 'upstream'" && git remote add upstream https://github.com/jackyzha0/quartz.git)
|
||||
git fetch upstream
|
||||
git log --oneline --decorate --graph ..upstream/hugo
|
||||
git checkout -p upstream/hugo -- layouts .github Makefile assets/js assets/styles/base.scss assets/styles/darkmode.scss config.toml data
|
||||
|
||||
update-force: ## Forcefully pull all changes and don't ask to patch
|
||||
go install github.com/jackyzha0/hugo-obsidian@latest
|
||||
@git remote show upstream || (echo "remote 'upstream' not present, setting 'upstream'" && git remote add upstream https://github.com/jackyzha0/quartz.git)
|
||||
git fetch upstream
|
||||
git checkout upstream/hugo -- layouts .github Makefile assets/js assets/styles/base.scss assets/styles/darkmode.scss config.toml data
|
||||
|
||||
@ -1,37 +1,60 @@
|
||||
async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLegend, enableZoom) {
|
||||
async function drawGraph(
|
||||
baseUrl,
|
||||
pathColors,
|
||||
depth,
|
||||
enableDrag,
|
||||
enableLegend,
|
||||
enableZoom
|
||||
) {
|
||||
const container = document.getElementById('graph-container')
|
||||
const { index, links, content } = await fetchData
|
||||
const curPage = url.replace(baseUrl, "")
|
||||
|
||||
const parseIdsFromLinks = (links) => [...(new Set(links.flatMap(link => ([link.source, link.target]))))]
|
||||
// Use .pathname to remove hashes / searchParams / text fragments
|
||||
const cleanUrl = window.location.origin + window.location.pathname
|
||||
|
||||
const curPage = cleanUrl.replace(/\/$/g, "").replace(baseUrl, "")
|
||||
|
||||
const parseIdsFromLinks = (links) => [
|
||||
...new Set(links.flatMap((link) => [link.source, link.target])),
|
||||
]
|
||||
|
||||
// Links is mutated by d3. We want to use links later on, so we make a copy and pass that one to d3
|
||||
// Note: shallow cloning does not work because it copies over references from the original array
|
||||
const copyLinks = JSON.parse(JSON.stringify(links))
|
||||
|
||||
const neighbours = new Set()
|
||||
const wl = [curPage || "/", "__SENTINEL"]
|
||||
const wl = [curPage || '/', '__SENTINEL']
|
||||
if (depth >= 0) {
|
||||
while (depth >= 0 && wl.length > 0) {
|
||||
// compute neighbours
|
||||
const cur = wl.shift()
|
||||
if (cur === "__SENTINEL") {
|
||||
if (cur === '__SENTINEL') {
|
||||
depth--
|
||||
wl.push("__SENTINEL")
|
||||
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))
|
||||
wl.push(
|
||||
...outgoing.map((l) => l.target),
|
||||
...incoming.map((l) => l.source)
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
parseIdsFromLinks(links).forEach(id => neighbours.add(id))
|
||||
parseIdsFromLinks(copyLinks).forEach((id) => neighbours.add(id))
|
||||
}
|
||||
|
||||
const data = {
|
||||
nodes: [...neighbours].map(id => ({ id })),
|
||||
links: links.filter(l => neighbours.has(l.source) && neighbours.has(l.target)),
|
||||
nodes: [...neighbours].map((id) => ({ id })),
|
||||
links: copyLinks.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)"
|
||||
if (d.id === curPage || (d.id === '/' && curPage === '')) {
|
||||
return 'var(--g-node-active)'
|
||||
}
|
||||
|
||||
for (const pathColor of pathColors) {
|
||||
@ -42,179 +65,219 @@ async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLege
|
||||
}
|
||||
}
|
||||
|
||||
return "var(--g-node)"
|
||||
return 'var(--g-node)'
|
||||
}
|
||||
|
||||
const drag = simulation => {
|
||||
const drag = (simulation) => {
|
||||
function dragstarted(event, d) {
|
||||
if (!event.active) simulation.alphaTarget(1).restart();
|
||||
d.fx = d.x;
|
||||
d.fy = d.y;
|
||||
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;
|
||||
d.fx = event.x
|
||||
d.fy = event.y
|
||||
}
|
||||
|
||||
function dragended(event, d) {
|
||||
if (!event.active) simulation.alphaTarget(0);
|
||||
d.fx = null;
|
||||
d.fy = null;
|
||||
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);
|
||||
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 height = Math.max(container.offsetHeight, 250)
|
||||
const width = 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 simulation = d3
|
||||
.forceSimulation(data.nodes)
|
||||
.force('charge', d3.forceManyBody().strength(-30))
|
||||
.force(
|
||||
'link',
|
||||
d3
|
||||
.forceLink(data.links)
|
||||
.id((d) => d.id)
|
||||
.distance(40)
|
||||
)
|
||||
.force('center', d3.forceCenter())
|
||||
|
||||
const svg = d3.select('#graph-container')
|
||||
const svg = d3
|
||||
.select('#graph-container')
|
||||
.append('svg')
|
||||
.attr('width', width)
|
||||
.attr('height', height)
|
||||
.attr("viewBox", [-width / 2, -height / 2, width, height]);
|
||||
.attr('viewBox', [-width / 2, -height / 2, width, height])
|
||||
|
||||
if (enableLegend) {
|
||||
const legend = [
|
||||
{ "Current": "var(--g-node-active)" },
|
||||
{ "Note": "var(--g-node)" },
|
||||
...pathColors
|
||||
{ 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")
|
||||
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")
|
||||
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)
|
||||
.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")
|
||||
const graphNode = svg
|
||||
.append('g')
|
||||
.selectAll('g')
|
||||
.data(data.nodes)
|
||||
.enter().append("g")
|
||||
.enter()
|
||||
.append('g')
|
||||
|
||||
// draw individual nodes
|
||||
const node = graphNode.append("circle")
|
||||
.attr("class", "node")
|
||||
.attr("id", (d) => d.id)
|
||||
.attr("r", (d) => {
|
||||
// calculate radius
|
||||
const nodeRadius = (d) => {
|
||||
const numOut = index.links[d.id]?.length || 0
|
||||
const numIn = index.backlinks[d.id]?.length || 0
|
||||
return 3 + (numOut + numIn) / 4
|
||||
}
|
||||
|
||||
// draw individual nodes
|
||||
const node = graphNode
|
||||
.append('circle')
|
||||
.attr('class', 'node')
|
||||
.attr('id', (d) => d.id)
|
||||
.attr('r', nodeRadius)
|
||||
.attr('fill', color)
|
||||
.style('cursor', 'pointer')
|
||||
.on('click', (_, d) => {
|
||||
// SPA navigation
|
||||
window.navigate(
|
||||
new URL(`${baseUrl}${decodeURI(d.id).replace(/\s+/g, '-')}/`),
|
||||
'.singlePage'
|
||||
)
|
||||
})
|
||||
.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")
|
||||
.on('mouseover', function(_, d) {
|
||||
d3.selectAll('.node')
|
||||
.transition()
|
||||
.duration(100)
|
||||
.attr("fill", "var(--g-node-inactive)")
|
||||
.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 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)
|
||||
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)
|
||||
neighbourNodes.transition().duration(200).attr('fill', color)
|
||||
|
||||
// highlight links
|
||||
linkNodes
|
||||
.transition()
|
||||
.duration(200)
|
||||
.attr("stroke", "var(--g-link-active)")
|
||||
.attr('stroke', 'var(--g-link-active)')
|
||||
|
||||
// show text for self
|
||||
d3.select(this.parentNode)
|
||||
.select("text")
|
||||
.raise()
|
||||
.select('text')
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style("opacity", 1)
|
||||
}).on("mouseleave", function(_, d) {
|
||||
d3.selectAll(".node")
|
||||
.transition()
|
||||
.duration(200)
|
||||
.attr("fill", color)
|
||||
.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)
|
||||
const linkNodes = d3
|
||||
.selectAll('.link')
|
||||
.filter((d) => d.source.id === currentId || d.target.id === currentId)
|
||||
|
||||
linkNodes
|
||||
.transition()
|
||||
.duration(200)
|
||||
.attr("stroke", "var(--g-link)")
|
||||
linkNodes.transition().duration(200).attr('stroke', 'var(--g-link)')
|
||||
|
||||
d3.select(this.parentNode)
|
||||
.select("text")
|
||||
.select('text')
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style("opacity", 0)
|
||||
.style('opacity', 0)
|
||||
})
|
||||
.call(drag(simulation));
|
||||
.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));
|
||||
const labels = graphNode
|
||||
.append('text')
|
||||
.attr('dx', 0)
|
||||
.attr('dy', (d) => nodeRadius(d) + 8 + 'px')
|
||||
.attr('text-anchor', 'middle')
|
||||
.text((d) => content[d.id]?.title || d.id.replace('-', ' '))
|
||||
.style('opacity', 0)
|
||||
.style('pointer-events', 'none')
|
||||
.style('font-size', '0.4em')
|
||||
.raise()
|
||||
.call(drag(simulation))
|
||||
|
||||
// set panning
|
||||
|
||||
if (enableZoom) {
|
||||
svg.call(d3.zoom()
|
||||
.extent([[0, 0], [width, height]])
|
||||
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);
|
||||
}));
|
||||
.on('zoom', ({ transform }) => {
|
||||
link.attr('transform', transform)
|
||||
node.attr('transform', transform)
|
||||
const scale = transform.k
|
||||
const scaledOpacity = Math.max((scale - 1) / 3.75, 0)
|
||||
labels.attr('transform', transform).style('opacity', scaledOpacity)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
// progress the simulation
|
||||
simulation.on("tick", () => {
|
||||
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)
|
||||
});
|
||||
.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)
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,27 +1,51 @@
|
||||
function htmlToElement(html) {
|
||||
const template = document.createElement('template')
|
||||
const template = document.createElement("template")
|
||||
html = html.trim()
|
||||
template.innerHTML = html
|
||||
return template.content.firstChild
|
||||
}
|
||||
|
||||
function initPopover(baseURL) {
|
||||
function initPopover(baseURL, useContextualBacklinks, renderLatex) {
|
||||
const basePath = baseURL.replace(window.location.origin, "")
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
fetchData.then(({ content }) => {
|
||||
const links = [...document.getElementsByClassName("internal-link")]
|
||||
links
|
||||
.filter(li => li.dataset.src)
|
||||
.filter(li => li.dataset.src || (li.dataset.idx && useContextualBacklinks))
|
||||
.forEach(li => {
|
||||
const linkDest = content[li.dataset.src.replace(basePath, "")]
|
||||
var el
|
||||
if (li.dataset.ctx) {
|
||||
const linkDest = content[li.dataset.src]
|
||||
const popoverElement = `<div class="popover">
|
||||
<h3>${linkDest.title}</h3>
|
||||
<p>${highlight(removeMarkdown(linkDest.content), li.dataset.ctx)}...</p>
|
||||
<p class="meta">${new Date(linkDest.lastmodified).toLocaleDateString()}</p>
|
||||
</div>`
|
||||
el = htmlToElement(popoverElement)
|
||||
} else {
|
||||
const linkDest = content[li.dataset.src.replace(/\/$/g, "").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)
|
||||
el = htmlToElement(popoverElement)
|
||||
}
|
||||
}
|
||||
|
||||
if (el) {
|
||||
li.appendChild(el)
|
||||
if (renderLatex) {
|
||||
renderMathInElement(el, {
|
||||
delimiters: [
|
||||
{ left: '$$', right: '$$', display: false },
|
||||
{ left: '$', right: '$', display: false },
|
||||
{ left: '\\(', right: '\\)', display: false },
|
||||
{ left: '\\[', right: '\\]', display: false }
|
||||
],
|
||||
throwOnError: false
|
||||
})
|
||||
}
|
||||
li.addEventListener("mouseover", () => {
|
||||
el.classList.add("visible")
|
||||
})
|
||||
@ -31,5 +55,4 @@ function initPopover(baseURL) {
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
12
assets/js/router.js
Normal file
12
assets/js/router.js
Normal file
@ -0,0 +1,12 @@
|
||||
import { router, navigate } from "https://unpkg.com/million@1.8.9-0/dist/router.mjs"
|
||||
|
||||
export const attachSPARouting = (draw) => {
|
||||
// SPA navigation for access later
|
||||
window.navigate = navigate
|
||||
// We only mutate document.title and content within .singlePage element
|
||||
router(".singlePage")
|
||||
// We need on initial load, then subsequent redirs
|
||||
// requestAnimationFrame() delays graph draw until SPA routing is finished
|
||||
window.addEventListener("million:navigate", () => requestAnimationFrame(draw))
|
||||
window.addEventListener("DOMContentLoaded", () => requestAnimationFrame(draw))
|
||||
}
|
||||
@ -9,94 +9,82 @@ const removeMarkdown = (
|
||||
preserveLinks: false,
|
||||
}
|
||||
) => {
|
||||
let output = markdown || "";
|
||||
output = output.replace(/^(-\s*?|\*\s*?|_\s*?){3,}\s*$/gm, "");
|
||||
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");
|
||||
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, "");
|
||||
.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, '$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");
|
||||
.replace(/<[^>]*>/g, '')
|
||||
.replace(/^[=\-]{2,}\s*$/g, '')
|
||||
.replace(/\[\^.+?\](\: .*?$)?/g, '')
|
||||
.replace(/(#{1,6})\s+(.+)\1?/g, '<b>$2</b>')
|
||||
.replace(/\s{0,2}\[.*?\]: .*?$/g, '')
|
||||
.replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, options.useImgAltText ? '$1' : '')
|
||||
.replace(/\[(.*?)\][\[\(].*?[\]\)]/g, '<a>$1</a>')
|
||||
.replace(/!?\[\[\S[^\[\]\|]*(?:\|([^\[\]]*))?\S\]\]/g, '<a>$1</a>')
|
||||
.replace(/^\s{0,3}>\s?/g, '')
|
||||
.replace(/(^|\n)\s{0,3}>\s?/g, '\n\n')
|
||||
.replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g, '')
|
||||
.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;
|
||||
console.error(e)
|
||||
return markdown
|
||||
}
|
||||
return output
|
||||
}
|
||||
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)
|
||||
// try to find direct match first
|
||||
const directMatchIdx = content.indexOf(term)
|
||||
if (directMatchIdx !== -1) {
|
||||
const h = highlightWindow / 2
|
||||
const before = content.substring(0, directMatchIdx).split(" ").slice(-h)
|
||||
const after = content.substring(directMatchIdx + term.length, content.length - 1).split(" ").slice(0, h)
|
||||
return (before.length == h ? `...${before.join(" ")}` : before.join(" ")) + `<span class="search-highlight">${term}</span>` + after.join(" ")
|
||||
}
|
||||
|
||||
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++) {
|
||||
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) {
|
||||
@ -106,18 +94,51 @@ const removeMarkdown = (
|
||||
}
|
||||
|
||||
const startIndex = Math.max(bestIndex - highlightWindow, 0)
|
||||
const endIndex = Math.min(startIndex + 2 * highlightWindow, splitText.length)
|
||||
const endIndex = Math.min(
|
||||
startIndex + 2 * highlightWindow,
|
||||
splitText.length
|
||||
)
|
||||
const mappedText = splitText
|
||||
.slice(startIndex, endIndex)
|
||||
.map(token => {
|
||||
.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 ? "" : "..."}`
|
||||
.join(' ')
|
||||
.replaceAll('</span> <span class="search-highlight">', ' ')
|
||||
return `${startIndex === 0 ? '' : '...'}${mappedText}${endIndex === splitText.length ? '' : '...'
|
||||
}`
|
||||
};
|
||||
|
||||
(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 resultToHTML = ({ url, title, content, term }) => {
|
||||
@ -131,22 +152,29 @@ const removeMarkdown = (
|
||||
}
|
||||
|
||||
const redir = (id, term) => {
|
||||
window.location.href = BASE_URL + `${id}#:~:text=${encodeURIComponent(term)}`
|
||||
// SPA navigation
|
||||
window.navigate(
|
||||
new URL(
|
||||
`${BASE_URL.replace(/\/$/g, "")}${id}#:~:text=${encodeURIComponent(term)}/`
|
||||
),
|
||||
'.singlePage'
|
||||
)
|
||||
closeSearch()
|
||||
}
|
||||
|
||||
const formatForDisplay = id => ({
|
||||
const formatForDisplay = (id) => ({
|
||||
id,
|
||||
url: id,
|
||||
title: content[id].title,
|
||||
content: content[id].content
|
||||
content: content[id].content,
|
||||
})
|
||||
|
||||
const source = document.getElementById('search-bar')
|
||||
const results = document.getElementById("results-container")
|
||||
const results = document.getElementById('results-container')
|
||||
let term
|
||||
source.addEventListener("keyup", (e) => {
|
||||
if (e.key === "Enter") {
|
||||
const anchor = document.getElementsByClassName("result-card")[0]
|
||||
source.addEventListener('keyup', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
const anchor = document.getElementsByClassName('result-card')[0]
|
||||
redir(anchor.id, term)
|
||||
}
|
||||
})
|
||||
@ -154,16 +182,16 @@ const removeMarkdown = (
|
||||
term = e.target.value
|
||||
const searchResults = contentIndex.search(term, [
|
||||
{
|
||||
field: "content",
|
||||
field: 'content',
|
||||
limit: 10,
|
||||
},
|
||||
{
|
||||
field: "title",
|
||||
field: 'title',
|
||||
limit: 5,
|
||||
}
|
||||
},
|
||||
])
|
||||
const getByField = field => {
|
||||
const results = searchResults.filter(x => x.field === field)
|
||||
const getByField = (field) => {
|
||||
const results = searchResults.filter((x) => x.field === field)
|
||||
if (results.length === 0) {
|
||||
return []
|
||||
} else {
|
||||
@ -181,48 +209,52 @@ const removeMarkdown = (
|
||||
</button>`
|
||||
} else {
|
||||
results.innerHTML = finalResults
|
||||
.map(result => resultToHTML({
|
||||
.map((result) =>
|
||||
resultToHTML({
|
||||
...result,
|
||||
term,
|
||||
}))
|
||||
.join("\n")
|
||||
const anchors = document.getElementsByClassName("result-card");
|
||||
[...anchors].forEach(anchor => {
|
||||
})
|
||||
)
|
||||
.join('\n')
|
||||
const anchors = [...document.getElementsByClassName('result-card')]
|
||||
anchors.forEach((anchor) => {
|
||||
anchor.onclick = () => redir(anchor.id, term)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const searchContainer = document.getElementById("search-container")
|
||||
const searchContainer = document.getElementById('search-container')
|
||||
|
||||
function openSearch() {
|
||||
if (searchContainer.style.display === "none" || searchContainer.style.display === "") {
|
||||
source.value = ""
|
||||
results.innerHTML = ""
|
||||
searchContainer.style.display = "block"
|
||||
if (
|
||||
searchContainer.style.display === 'none' ||
|
||||
searchContainer.style.display === ''
|
||||
) {
|
||||
source.value = ''
|
||||
results.innerHTML = ''
|
||||
searchContainer.style.display = 'block'
|
||||
source.focus()
|
||||
} else {
|
||||
searchContainer.style.display = "none"
|
||||
searchContainer.style.display = 'none'
|
||||
}
|
||||
}
|
||||
|
||||
function closeSearch() {
|
||||
searchContainer.style.display = "none"
|
||||
searchContainer.style.display = 'none'
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', (event) => {
|
||||
if (event.key === "k" && (event.ctrlKey || event.metaKey)) {
|
||||
if (event.key === 'k' && (event.ctrlKey || event.metaKey)) {
|
||||
event.preventDefault()
|
||||
openSearch()
|
||||
}
|
||||
if (event.key === "Escape") {
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault()
|
||||
closeSearch()
|
||||
}
|
||||
})
|
||||
|
||||
const searchButton = document.getElementById("search-icon")
|
||||
const searchButton = document.getElementById('search-icon')
|
||||
searchButton.addEventListener('click', (evt) => {
|
||||
openSearch()
|
||||
})
|
||||
@ -232,8 +264,7 @@ const removeMarkdown = (
|
||||
searchContainer.addEventListener('click', (evt) => {
|
||||
closeSearch()
|
||||
})
|
||||
document.getElementById("search-space").addEventListener('click', (evt) => {
|
||||
document.getElementById('search-space').addEventListener('click', (evt) => {
|
||||
evt.stopPropagation()
|
||||
})
|
||||
})()
|
||||
|
||||
|
||||
@ -12,6 +12,19 @@ h1, h2, h3, h4, h5, h6, ol, ul, thead {
|
||||
font-weight: revert;
|
||||
margin: revert;
|
||||
padding: revert;
|
||||
|
||||
&:hover > .hanchor {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.hanchor {
|
||||
font-family: Inter;
|
||||
margin-left: -1em;
|
||||
opacity: 0.3;
|
||||
transition: opacity 0.3s ease;
|
||||
color: var(--secondary);
|
||||
|
||||
}
|
||||
|
||||
p, ul, text {
|
||||
@ -329,6 +342,13 @@ hr {
|
||||
& #graph-container {
|
||||
border: var(--outlinegray) 1px solid;
|
||||
border-radius: 5px;
|
||||
box-sizing: border-box;
|
||||
min-height: 250px;
|
||||
|
||||
& > svg {
|
||||
margin-bottom: -5px;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,7 +441,7 @@ header {
|
||||
}
|
||||
|
||||
& > #results-container {
|
||||
& > .result-card {
|
||||
& .result-card {
|
||||
padding: 1em;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s ease;
|
||||
@ -458,16 +478,16 @@ header {
|
||||
& > h3, & > p {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
& .search-highlight {
|
||||
.search-highlight {
|
||||
background-color: #afbfc966;
|
||||
padding: 0.05em 0.2em;
|
||||
border-radius: 3px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.section-ul {
|
||||
list-style: none;
|
||||
@ -526,7 +546,7 @@ header {
|
||||
box-shadow: 6px 6px 36px 0px rgba(0,0,0,0.25);
|
||||
|
||||
@media all and (max-width: 600px) {
|
||||
display: none;
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
&.visible {
|
||||
@ -549,7 +569,7 @@ header {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
& > p {
|
||||
& > p, & > a {
|
||||
margin: 0;
|
||||
font-weight: 400;
|
||||
user-select: none;
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
{{$spacedurl := replace $trimmed "%20" " " }}
|
||||
{{$fixedUrl := (cond (hasPrefix $spacedurl "/") $spacedurl (print "/" $spacedurl)) | urlize}}
|
||||
{{$nonexistent := eq (.Page.GetPage $spacedurl).RelPermalink ""}}
|
||||
{{$rooted := default $spacedurl (strings.TrimRight "/" (.Page.GetPage $spacedurl).RelPermalink) }}
|
||||
{{$rooted := default $spacedurl ((.Page.GetPage $spacedurl).RelPermalink) }}
|
||||
<a
|
||||
{{if not $nonexistent}}href="{{$rooted}}"{{end}}
|
||||
rel="noopener" class="internal-link{{if $nonexistent}} broken{{end}}"
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
</article>
|
||||
{{partial "contact.html" .}}
|
||||
</div>
|
||||
{{partial "popover.html" .}}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@ -26,7 +26,6 @@
|
||||
{{partial "textprocessing.html" . }}
|
||||
</article>
|
||||
{{partial "footer.html" .}}
|
||||
{{partial "popover.html" .}}
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
</article>
|
||||
{{partial "contact.html" .}}
|
||||
</div>
|
||||
{{partial "popover.html" .}}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
</article>
|
||||
{{partial "contact.html" .}}
|
||||
</div>
|
||||
{{partial "popover.html" .}}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@ -17,8 +17,6 @@
|
||||
{{partial "textprocessing.html" . }}
|
||||
</article>
|
||||
{{partial "footer.html" .}}
|
||||
{{partial "popover.html" .}}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@ -7,12 +7,18 @@
|
||||
{{$inbound := index $linkIndex.index.backlinks $curPage}}
|
||||
{{$contentTable := getJSON "/assets/indices/contentIndex.json"}}
|
||||
{{if $inbound}}
|
||||
{{$cleanedInbound := apply (apply $inbound "index" "." "source") "replace" "." " " "-"}}
|
||||
{{- range $cleanedInbound | uniq -}}
|
||||
{{$l := printf "%s%s" $host .}}
|
||||
{{with (index $contentTable .)}}
|
||||
{{$backlinks := dict "SENTINEL" "SENTINEL"}}
|
||||
{{range $k, $v := $inbound}}
|
||||
{{$cleanedInbound := replace $v.source " " "-"}}
|
||||
{{$ctx := $v.text}}
|
||||
{{$backlinks = merge $backlinks (dict $cleanedInbound $ctx)}}
|
||||
{{end}}
|
||||
{{- range $lnk, $ctx := $backlinks -}}
|
||||
{{$l := printf "%s%s/" $host $lnk}}
|
||||
{{$l = cond (eq $l "//") "/" $l}}
|
||||
{{with (index $contentTable $lnk)}}
|
||||
<li>
|
||||
<a href="{{$l}}">{{index (index . "title")}}</a>
|
||||
<a href="{{$l}}" data-ctx="{{$ctx}}" data-src="{{$lnk}}" class="internal-link">{{index (index . "title")}}</a>
|
||||
</li>
|
||||
{{end}}
|
||||
{{- end -}}
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/d3@6.7.0/dist/d3.min.js" integrity="sha256-+7jaYCp29O1JusNWHaYtgUn6EhuP0VaFuswhNV06MyI=" crossorigin="anonymous"></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>
|
||||
<div id="graph-container"></div>
|
||||
<style>
|
||||
@ -12,14 +16,3 @@
|
||||
</style>
|
||||
{{ $js := resources.Get "js/graph.js" | resources.Fingerprint "md5" }}
|
||||
<script src="{{ $js.Permalink }}"></script>
|
||||
<script>
|
||||
drawGraph(
|
||||
{{strings.TrimRight "/" .Page.Permalink}},
|
||||
{{strings.TrimRight "/" .Site.BaseURL}},
|
||||
{{$.Site.Data.graphConfig.paths}},
|
||||
{{$.Site.Data.graphConfig.depth}},
|
||||
{{$.Site.Data.graphConfig.enableDrag}},
|
||||
{{$.Site.Data.graphConfig.enableLegend}},
|
||||
{{$.Site.Data.graphConfig.enableZoom}}
|
||||
)
|
||||
</script>
|
||||
|
||||
@ -1,13 +1,26 @@
|
||||
<head>
|
||||
<!-- Meta tags -->
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="{{if .IsHome}}{{$.Site.Data.config.description}}{{else}}{{.Summary}}{{end}}">
|
||||
<title>{{ if .Title }}{{ .Title }}{{ else }}{{ $.Site.Data.config.page_title }}{{ end }}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="shortcut icon" type="image/png" href="{{$.Site.BaseURL}}/icon.png" />
|
||||
<meta charset="UTF-8" />
|
||||
<meta
|
||||
name="description"
|
||||
content="{{if .IsHome}}{{$.Site.Data.config.description}}{{else}}{{.Summary}}{{end}}"
|
||||
/>
|
||||
<title>
|
||||
{{ if .Title }}{{ .Title }}{{ else }}{{ $.Site.Data.config.page_title }}{{
|
||||
end }}
|
||||
</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link
|
||||
rel="shortcut icon"
|
||||
type="image/png"
|
||||
href="{{$.Site.BaseURL}}/icon.png"
|
||||
/>
|
||||
|
||||
<!-- 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"
|
||||
/>
|
||||
{{$sass := resources.Match "styles/[!_]*.scss" }}
|
||||
{{$css := slice }}
|
||||
{{range $sass}}
|
||||
@ -15,15 +28,22 @@
|
||||
{{$css = $css | append $scss}}
|
||||
{{end}}
|
||||
{{$finalCss := $css | resources.Concat "styles.css" | resources.Fingerprint "md5" | resources.Minify }}
|
||||
<link href="{{$finalCss.Permalink}}" rel="stylesheet">
|
||||
<link href="{{$finalCss.Permalink}}" rel="stylesheet" />
|
||||
|
||||
{{ $darkMode := resources.Get "js/darkmode.js" | resources.Fingerprint "md5" | resources.Minify }}
|
||||
{{ $darkMode := resources.Get "js/darkmode.js" | resources.Fingerprint "md5" |
|
||||
resources.Minify }}
|
||||
<script src="{{$darkMode.Permalink}}"></script>
|
||||
{{partial "katex.html" .}}
|
||||
|
||||
{{ $popover := resources.Get "js/popover.js" | resources.Fingerprint "md5" |
|
||||
resources.Minify }}
|
||||
<script src="{{$popover.Permalink}}"></script>
|
||||
|
||||
<!-- 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 }}
|
||||
{{$linkIndex := resources.Get "indices/linkIndex.json" | resources.Fingerprint
|
||||
"md5" | resources.Minify | }} {{$contentIndex := resources.Get
|
||||
"indices/contentIndex.json" | resources.Fingerprint "md5" | resources.Minify
|
||||
}}
|
||||
<script>
|
||||
const BASE_URL = {{.Site.BaseURL}}
|
||||
const fetchData = Promise.all([
|
||||
@ -42,5 +62,49 @@
|
||||
content,
|
||||
}))
|
||||
</script>
|
||||
{{if $.Site.Data.config.enableSPA}}
|
||||
{{ $router := resources.Get "js/router.js" | resources.Fingerprint "md5" |
|
||||
resources.Minify }}
|
||||
<script type="module">
|
||||
import { attachSPARouting } from '{{$router.Permalink}}';
|
||||
// NOTE: everything within this callback will be executed for every page navigation. This is a good place to put JavaScript that loads or modifies data on the page.
|
||||
const draw = () => {
|
||||
const container = document.getElementById("graph-container")
|
||||
// retry if the graph is not ready
|
||||
if (!container) return requestAnimationFrame(draw)
|
||||
// clear the graph in case there is anything within it
|
||||
container.textContent = ""
|
||||
|
||||
drawGraph(
|
||||
{{strings.TrimRight "/" .Site.BaseURL}},
|
||||
{{$.Site.Data.graphConfig.paths}},
|
||||
{{$.Site.Data.graphConfig.depth}},
|
||||
{{$.Site.Data.graphConfig.enableDrag}},
|
||||
{{$.Site.Data.graphConfig.enableLegend}},
|
||||
{{$.Site.Data.graphConfig.enableZoom}}
|
||||
);
|
||||
|
||||
{{if $.Site.Data.config.enableLinkPreview}}
|
||||
initPopover(
|
||||
{{strings.TrimRight "/" .Site.BaseURL }},
|
||||
{{$.Site.Data.config.enableContextualBacklinks}},
|
||||
{{$.Site.Data.config.enableLatex}}
|
||||
)
|
||||
{{end}}
|
||||
{{if $.Site.Data.config.enableLatex}}
|
||||
renderMathInElement(document.body, {
|
||||
delimiters: [
|
||||
{left: '$$', right: '$$', display: true},
|
||||
{left: '$', right: '$', display: false},
|
||||
],
|
||||
throwOnError : false
|
||||
});
|
||||
{{end}}
|
||||
};
|
||||
attachSPARouting(draw);
|
||||
</script>
|
||||
{{else}}
|
||||
<script>window.navigate = (url) => window.location.href = url</script>
|
||||
{{end}}
|
||||
</head>
|
||||
{{ template "_internal/google_analytics.html" . }}
|
||||
|
||||
@ -2,15 +2,4 @@
|
||||
<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,7 +0,0 @@
|
||||
{{if $.Site.Data.config.enableLinkPreview}}
|
||||
{{ $js := resources.Get "js/popover.js" | resources.Fingerprint "md5" | resources.Minify }}
|
||||
<script src="{{ $js.Permalink }}"></script>
|
||||
<script>
|
||||
initPopover({{strings.TrimRight "/" .Site.BaseURL }})
|
||||
</script>
|
||||
{{end}}
|
||||
@ -53,4 +53,8 @@
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{/* Add copyable anchors */}}
|
||||
{{ $content = $content | replaceRE "(<h[1-9] id=\"([^\"]+)\">)(.+)(</h[1-9]>)" `<a href="#${2}">${1}<span class="hanchor" ariaLabel="Anchor"># </span>${3}${4}</a>` }}
|
||||
|
||||
{{ $content | safeHTML }}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user