List unresolved links as unlinked mentions

I figured it out! Here’s the code I’m using to get a list of dangling links that excludes my “_Meta” folder:

```dataviewjs
// Build the complete list of unresolved notes,
// with where they're defined as the origin
const unresolved = {}
Object.entries( dv.app.metadataCache.unresolvedLinks )
  .filter( ([origin, unresolvedList]) => 
           Object.keys(unresolvedList).length && !origin.startsWith("_Meta"))
  .forEach( ([origin, unresolvedList]) => {
    Object.entries( unresolvedList )
      .forEach( ([newNote, count]) => {
        if ( !unresolved[newNote] )
          unresolved[newNote] = []
          unresolved[newNote].push( dv.fileLink(origin) )
      })
  })

// Combine the two and list all unresolved notes,
// with a column listing where they're defined
dv.table(["Unresolved Link", "Link Origin(s)"],
  Object.entries(unresolved)
    .sort( (a, b) => (a[0].toLowerCase() < b[0].toLowerCase() ? -1 : 1) )
    .map( item => [dv.fileLink( item[0] ), item[1] ] )
  )
```

Sorry for not coming back to you sooner, but I’m glad you found your way around it. I was thinking about proposing something along the lines of doing:

.forEach( ([origin, unresolvedList]) => {
  if ( origin.startsWith("_Meta") )
    continue
  ...

That would generate a similar effect, but your solution of filtering in front of the loop is a very valid and sound solution.

1 Like