jekyll-scholar icon indicating copy to clipboard operation
jekyll-scholar copied to clipboard

Conditional by citation count

Open kaba2 opened this issue 4 years ago • 3 comments

How can I use bibliography_count inside conditionals? The following Jekyll code fails by "Unknown operator bibliography_count":

{% if {% bibliography_count --cited %} > 0 %}

<h2>References</h2>

{%- bibliography --cited -%}
{% endif %}

kaba2 avatar Jul 07 '20 02:07 kaba2

Here is a workaround. Is it supposed to work like this?

{%- capture citecount -%}
{%- bibliography_count --cited -%}
{%- endcapture -%}

{% if {{citecount}} != "0"  %}

<h2>References</h2>

{%- bibliography --cited -%}
{% endif %}

kaba2 avatar Jul 07 '20 03:07 kaba2

This was just what I was looking for. It would be great to add these instructions to the README.

AlasdairGray avatar Jul 27 '21 10:07 AlasdairGray

the above didn't work for me. this was my workaround:

{% comment %}
Capture cites so i can check for a populated list later
{% endcomment %}
{% capture cites %}
{% bibliography --cited_in_order %}
{% endcapture %}
{% comment %}
The bibliography tag returns an empty list if there are no citations
(nil would seem to make more sense, but hey)
Thus, check for a list element in the returned bibliography to indicate
I actually cited something in this article.
{% endcomment %}
{% if cites contains "<li" %} <section class="footnotes reference">
   <h1 id="">References</h1>
   {{cites | markdownify }}
   </section>
   {% endif %}

norseghost avatar Mar 16 '24 20:03 norseghost