alshedivat / al-folio

A beautiful, simple, clean, and responsive Jekyll theme for academics
https://alshedivat.github.io/al-folio/
MIT License
11.19k stars 11.24k forks source link

Include a link to bibtex in bib.html #146

Closed AbeHandler closed 3 years ago

AbeHandler commented 3 years ago

This is a neat theme. Thanks so much for the work on this so far.

Is your feature request related to a problem? Please describe.

I have noticed that some academics include links to bibtex on their publication's page, so that people can easily copy/paste/cite the correct .bibtex when looking over the paper. It would be great if al-folio supported this easily.

Describe the solution you'd like Allow for bibtex buttons on the publications page. When the user clicks the bibtex button, it reveals formatted bibtex so they can copy and paste the bibtex from the website. When the user clicks the button again, the bibtex is hidden. I think the behavior should be similar to the abstract, which is also hidden/shown on button click.

Describe alternatives you've considered I added a new key to my _bibliography/papers.bib and added the following to bib.html. This logic shows/hides the bibtex on click. I think it would be helpful for others if the bibtex could be cleanly formatted and this possibility could be spelled out in the docs.

    {% if entry.bibtex %}
        <a class="bibtex btn btn-sm z-depth-0" role="button">Bibtex</a>
    {% endif %}

     ...

    <!-- Hidden abstract block -->
    {% if entry.abstract %}
    <div class="abstract hidden">
      <p>{{ entry.abstract }}</p>
    </div>
    {% endif %}

    {% if entry.bibtex %}
    <div class="bibtex hidden">
      <p>{% highlight bibtex %}{{ entry.bibtex }}{% endhighlight %}</p>
    </div>
    {% endif %}
alshedivat commented 3 years ago

Thanks for the suggestion, @AbeHandler. Would you mind creating a PR that adds this functionality? The al-folio community (including myself) would appreciate that. The only request is to make the bibtex button optional.

AbeHandler commented 3 years ago

@alshedivat Yep. I will put in a PR soon. Thanks for this great theme.