theowenyoung / gatsby-theme-primer-wiki

A Gatsby Theme for Wiki/Docs/Knowledge Base, which using Primer style as the UI theme, can work well with Foam or Obsibian or just markdown files.
https://demo-wiki.owenyoung.com/
MIT License
118 stars 18 forks source link

Unable to see Backlinks #55

Open padosum opened 2 years ago

padosum commented 2 years ago

Hello, I want to say thank you for this theme. I'm using it well for learning. It's really nice. 😄

I recenlty discovered that "Backlinks (ReferencesBlock)" doesn't work. Since I don't know much about Gatsby, I kept trying to console.log again again again... In my opinion, in references/lib/compute-inbounds.jsfile,

function getInboundReferences(getNode, allNodes) {
  const nodes = allNodes;
  const slugs = Array.from(nodes.map((node) => node.fields.slug));

  const inboundReferences = {};
  function filterNodes(item) {
    return slugs.includes(item);
  }

  nodes.forEach((node) => {
    const mapped = node.__outboundReferencesSlugs // slug array
      .filter(filterNodes)
      .map((x) => x.id); // no id attribute

node._outboundReferencesSlugs has only slug values, so in the map, 'id' is undefined.

If my thinking is correct, is it okay to modify it and make a pull request?

theowenyoung commented 2 years ago

yeah, maybe this is a bug, so we can remove the map function? please try it when you remove the map function, if it works, sure, please make a pr!