forked from ppeetteerrs/obsidian-zola
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Peter Yuen
authored and
Peter Yuen
committed
Apr 12, 2022
1 parent
06d7171
commit 6f9fee5
Showing
19 changed files
with
178 additions
and
227 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
#!/bin/bash | ||
|
||
pip install matplotlib | ||
|
||
echo "netlify.toml" >> __obsidian/.gitignore | ||
mkdir __site/content/docs | ||
|
||
wget https://github.com/zoni/obsidian-export/releases/download/v22.1.0/obsidian-export_Linux-x86_64.bin -O export.bin | ||
chmod +x export.bin | ||
./export.bin --frontmatter=never --hard-linebreaks --no-recursive-embeds __obsidian __site/content/docs | ||
rsync -avh __site/zola/ __site/build | ||
rsync -avh __site/content/ __site/build/content | ||
|
||
mkdir -p __site/build/content/docs | ||
|
||
__site/bin/obsidian-export --frontmatter=never --hard-linebreaks --no-recursive-embeds __obsidian __site/build/content/docs | ||
|
||
python __site/convert.py | ||
|
||
zola --root __site build --output-dir public | ||
zola --root __site/build build --output-dir public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
body.graph { | ||
body.home { | ||
height: 100vh; | ||
display: flex; | ||
flex-flow: column; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,91 @@ | ||
var container = document.getElementById("graph"); | ||
|
||
var nodes = new vis.DataSet(graph_data.nodes) | ||
var edges = new vis.DataSet(graph_data.edges) | ||
|
||
// Query dark mode setting | ||
function isDark() { | ||
return localStorage.getItem('theme') === 'dark' || (!localStorage.getItem('theme') && window.matchMedia("(prefers-color-scheme: dark)").matches) | ||
return localStorage.getItem('theme') === 'dark' || (!localStorage.getItem('theme') && window.matchMedia("(prefers-color-scheme: dark)").matches); | ||
} | ||
|
||
// Get URL of current page | ||
var curr_url = decodeURI(window.location.href.replace(location.origin, "")); | ||
if (curr_url.endsWith("/")) { | ||
curr_url = curr_url.slice(0, -1) | ||
} | ||
|
||
// Get graph element | ||
var container = document.getElementById("graph"); | ||
|
||
// Get nodes and edges from generated javascript | ||
var nodes = new vis.DataSet(graph_data.nodes); | ||
var edges = new vis.DataSet(graph_data.edges); | ||
|
||
// Construct graph | ||
var options = { | ||
nodes: { | ||
shape: "box", | ||
shape: "dot", | ||
color: isDark() ? "#8c8e91" : "#dee2e6", | ||
font: { | ||
face: "Tahoma", | ||
face: "Inter", | ||
color: isDark() ? "#c9cdd1" : "#616469", | ||
strokeColor: isDark() ? "#c9cdd1" : "#616469", | ||
}, | ||
scaling: { | ||
label: { | ||
enabled: true | ||
} | ||
} | ||
}, | ||
}, | ||
edges: { | ||
color: { inherit: "both" }, | ||
width: 4, | ||
width: 0.8, | ||
smooth: { | ||
type: "continuous", | ||
}, | ||
hoverWidth: 4, | ||
}, | ||
interaction: { | ||
hover: true | ||
hover: true, | ||
}, | ||
height: "100%", | ||
width: "100%", | ||
physics: { | ||
solver: "repulsion" | ||
} | ||
}; | ||
|
||
var graph = new vis.Network(container, { | ||
nodes: nodes, | ||
edges: edges | ||
}, options); | ||
|
||
// Clickable URL | ||
graph.on("selectNode", function (params) { | ||
// console.log(params); | ||
if (params.nodes.length === 1) { | ||
var node = nodes.get(params.nodes[0]); | ||
window.open(node.url, "_blank"); | ||
} | ||
}); | ||
|
||
// Focus on current node + scaling | ||
graph.once("afterDrawing", function () { | ||
var curr_node = nodes.get({ | ||
filter: node => node.url == curr_url | ||
}); | ||
console.log(curr_url); | ||
if (curr_node.length > 0) { | ||
var idx = curr_node[0].id; | ||
graph.focus(idx, { | ||
scale: graph.getScale() * 1.8 | ||
}); | ||
nodes.update({ | ||
id: idx, | ||
value: 3, | ||
color: "#6667AB", | ||
borderWidth: 3, | ||
font: { | ||
strokeWidth: 1 | ||
} | ||
}); | ||
} else { | ||
graph.moveTo({ | ||
scale: graph.getScale() * 1.8 | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
// Set darkmode | ||
function isDark() { | ||
return document.body.classList.contains('dark') | ||
} | ||
|
||
document.getElementById('mode').addEventListener('click', () => { | ||
|
||
document.body.classList.toggle('dark'); | ||
localStorage.setItem('theme', document.body.classList.contains('dark') ? 'dark' : 'light'); | ||
|
||
document.body.classList.toggle('dark'); | ||
|
||
localStorage.setItem('theme', isDark() ? 'dark' : 'light'); | ||
|
||
// Update graph colors if exists | ||
if (graph) { | ||
graph.setOptions({ | ||
nodes: { | ||
color: isDark() ? "#8c8e91" : "#dee2e6", | ||
font: { | ||
color: isDark() ? "#c9cdd1" : "#616469", | ||
strokeColor: isDark() ? "#c9cdd1" : "#616469", | ||
} | ||
} | ||
}); | ||
} | ||
|
||
}); | ||
|
||
// enforce local storage setting but also fallback to user-agent preferences | ||
if (localStorage.getItem('theme') === 'dark' || (!localStorage.getItem('theme') && window.matchMedia("(prefers-color-scheme: dark)").matches)) { | ||
|
||
document.body.classList.add('dark'); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.