Remove duplicates in graph

This commit is contained in:
Ole Eskild Steensen 2022-10-13 18:20:45 +02:00
parent 21b9897782
commit dede9d091d

View File

@ -32,6 +32,8 @@
return x; return x;
}); });
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 = {
title, title,
@ -41,12 +43,13 @@
const gData = { const gData = {
nodes: [ nodes: [
currentNode, ...backLinks, currentNode,
...outbound ...backLinks,
...outboundDuplicatesRemoved
], ],
links: [ links: [
...backLinks.map(backlink => ({source: backlink.id, target: 0})), ...backLinks.map(backlink => ({source: backlink.id, target: 0})),
...outbound.map(outlink => ({source: 0, target: outlink.id})) ...outboundDuplicatesRemoved.map(outlink => ({source: 0, target: outlink.id}))
] ]
}; };