This commit is contained in:
Ole Eskild Steensen 2022-10-31 14:31:43 +01:00
parent 37a73b82a2
commit 725a211252

View File

@ -32,7 +32,7 @@
return x; return x;
}); });
const outboundDuplicatesRemoved = outbound.filter(x=>!backLinks.find(b=>b.url === x.url)); const outboundDuplicatesRemoved = outbound.filter(x => !backLinks.find(b => b.url === x.url));
const title = "{{page.fileSlug}}" || "Home" const title = "{{page.fileSlug}}" || "Home"
const currentNode = { const currentNode = {
@ -56,25 +56,32 @@
gData gData
.links .links
.forEach(link => { .forEach(link => {
const a = gData.nodes[link.source]; const a = gData
const b = gData.nodes[link.target]; .nodes
!a.neighbors && (a.neighbors = []); .find(x => x.id === link.source);
!b.neighbors && (b.neighbors = []); const b = gData
a .nodes
.neighbors .find(x => x.id === link.target);
.push(b); if (a && b) {
b
.neighbors
.push(a);
!a.links && (a.links = []); !a.neighbors && (a.neighbors = []);
!b.links && (b.links = []); !b.neighbors && (b.neighbors = []);
a a
.links .neighbors
.push(link); .push(b);
b b
.links .neighbors
.push(link); .push(a);
!a.links && (a.links = []);
!b.links && (b.links = []);
a
.links
.push(link);
b
.links
.push(link);
}
}); });
let Graph; let Graph;
@ -96,7 +103,7 @@
.nodeCanvasObject((node, ctx) => { .nodeCanvasObject((node, ctx) => {
const numberOfLinks = (node.links && node.links.length) || 2; const numberOfLinks = (node.links && node.links.length) || 2;
const numberOfNeighbours = (node.neighbors && node.neighbors.length) || 2; const numberOfNeighbours = (node.neighbors && node.neighbors.length) || 2;
const nodeR = Math.min(7, Math.max((numberOfLinks + numberOfNeighbours)/2, 2)); const nodeR = Math.min(7, Math.max((numberOfLinks + numberOfNeighbours) / 2, 2));
ctx.beginPath(); ctx.beginPath();
ctx.arc(node.x, node.y, nodeR, 0, 2 * Math.PI, false); ctx.arc(node.x, node.y, nodeR, 0, 2 * Math.PI, false);
ctx.fillStyle = getCssVar("--text-accent"); ctx.fillStyle = getCssVar("--text-accent");