jekyll-scholar
jekyll-scholar copied to clipboard
Conditional by citation count
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 %}
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 %}
This was just what I was looking for. It would be great to add these instructions to the README.
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 %}