inukshuk / jekyll-scholar

jekyll extensions for the blogging scholar
MIT License
1.12k stars 102 forks source link

Backlinks? #344

Open sneakers-the-rat opened 1 year ago

sneakers-the-rat commented 1 year ago

Hello again!

I'd love to add support for backlinks - after the reference in the bibliography, links back to the in-text citations. I think it should be relatively straightforward:

Normally i'd just dig my way through the code and figure out how to do this myself, but am sort of on a tight timeline. I'd be happy to draft it, but it would be helpful to have some pointers where I might go to do this.

Thanks again for your work on this plugin!!!!

inukshuk commented 1 year ago

Good idea!

The in-text citation links are created around here. If I'm not mistaken you can just add additional attributes there at the end, besides the class attribute. I guess the most tricky question here is how to deal with references that are cited multiple times. The cited keys themselves are tracked in the render_citation helper and we could probably re-purpose this a to also keep track of the number of citations.

When rendering the bibliography, the links to the details pages are ]optionally added to each reference](https://github.com/inukshuk/jekyll-scholar/blob/master/lib/jekyll/scholar/tags/bibliography.rb#L64). I'd guess that's where we'd want to insert the backlinks. All the helpers from the utilities module are available in the tag here. So I'd suggest to add a helper that creates the backlink id for an entry's id plus the usage count (and optionally a configurable prefix as you suggest).