Jacky Zhao
2022-02-15 0dc51ff39c9c867dd85c37a01c366cd5f278f032
layouts/partials/graph.html
@@ -11,10 +11,7 @@
    }
</style>
<script>
  const index = {{$.Site.Data.linkIndex.index}}
  const links = {{$.Site.Data.linkIndex.links}}
  const content = {{$.Site.Data.contentIndex}}
  const curPage = {{ strings.TrimRight "/" .Page.RelPermalink }}
  const curPage = {{ strings.TrimRight "/" .Page.Permalink }}.replace({{strings.TrimRight "/" .Site.BaseURL }}, "")
  const pathColors = {{$.Site.Data.graphConfig.paths}}
  let depth = {{$.Site.Data.graphConfig.depth}}
@@ -26,7 +23,6 @@
    while (depth >= 0 && wl.length > 0) {
      // compute neighbours
      const cur = wl.shift()
      console.log(depth, cur, wl)
      if (cur === "__SENTINEL") {
        depth--
        wl.push("__SENTINEL")
@@ -34,7 +30,6 @@
        neighbours.add(cur)
        const outgoing = index.links[cur] || []
        const incoming = index.backlinks[cur] || []
        console.log(incoming)
        wl.push(...outgoing.map(l => l.target), ...incoming.map(l => l.source))
      }
    }
@@ -148,7 +143,7 @@
    .attr("fill", color)
    .style("cursor", "pointer")
    .on("click", (_, d) => {
      window.location.href = {{.Site.BaseURL}} + d.id.replace(" ", "-").replace("%20", "-");
      window.location.href = {{.Site.BaseURL}} + decodeURI(d.id).replace(/\s+/g, '-')
    })
    .on("mouseover", function (_, d) {
      d3.selectAll(".node")
@@ -206,7 +201,7 @@
  const labels = graphNode.append("text")
    .attr("dx", 12)
    .attr("dy", ".35em")
    .text((d) => content[d.id.replace("%20", "-")]?.title || "Untitled")
    .text((d) => content[decodeURI(d.id).replace(/\s+/g, '-')]?.title || "Untitled")
    .style("opacity", 0)
    .style("pointer-events", "none")
    .call(drag(simulation));