coddingtonbear / obsidian-local-rest-api

Unlock your automation needs by interacting with your notes in Obsidian over a secure REST API.
MIT License
607 stars 56 forks source link

Add backlinks to GET vault/:file response #40

Closed AlgusDark closed 1 year ago

AlgusDark commented 1 year ago

Thanks for this awesome project. I believe that adding backlinks in the response of this endpoint would be a nice addition. I didn't have too much time looking at the code, but maybe the change for that is in the getFileMetadataObject function adding this:

interface BacklinkMetadata{
  displayText: string
  link: string
  original: string
  position: { start: any, end: any }
}

interface BacklinksResponse{
  data: {
    [filename: string]: Array<BacklinkMetadata>
  }
}

const backlinks: BacklinksResponse = this.app.metadataCache.getBacklinksForFile(file);