Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support max_author_limit #732

Merged
merged 9 commits into from
Jul 10, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ scholar:

filtered_bibtex_keywords: [abbr, abstract, arxiv, bibtex_show, html, pdf, selected, supp, blog, code, poster, slides, website] # Filter out certain bibtex entry keywords used internally from the bib output

max_author_limit: # maximum number of authors to be shown, other authors will be visible on hover, leave blank to show all authors

# -----------------------------------------------------------------------------
# Responsive WebP Images
# -----------------------------------------------------------------------------
Expand Down
31 changes: 27 additions & 4 deletions _layouts/bib.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@
<div class="title">{{entry.title}}</div>
<!-- Author -->
<div class="author">
{%- for author in entry.author_array -%}
{% assign author_array_size = entry.author_array | size %}

{%- if site.max_author_limit and author_array_size > site.max_author_limit %}
{% assign author_array_limit = site.max_author_limit %}
{% else %}
{% assign author_array_limit = author_array_size %}
{% endif %}

{%- for author in entry.author_array limit: author_array_limit -%}
{%- assign author_is_self = false -%}
{%- if author.last == site.scholar.last_name%}
{%- if site.scholar.first_name contains author.first -%}
Expand Down Expand Up @@ -57,17 +65,32 @@
{%- endif -%}
{%- else -%}
{% if author_is_self -%}
and <em>{{author.last}}, {{author.first}}</em>
{%- if author_array_limit == author_array_size %}and {% endif %}
<em>{{author.last}}, {{author.first}}</em>
{% else -%}
{%- if coauthor_url -%}
and <a href="{{coauthor_url}}">{{author.last}}, {{author.first}}</a>
{%- if author_array_limit == author_array_size %}and {% endif %}
<a href="{{coauthor_url}}">{{author.last}}, {{author.first}}</a>
{% else -%}
and {{author.last}}, {{author.first}}
{%- if author_array_limit == author_array_size %}and {% endif %}
{{author.last}}, {{author.first}}
{%- endif -%}
{%- endif -%}
{%- endunless -%}
{%- endif -%}
{%- endfor %}

{% assign more_authors = author_array_size | minus: author_array_limit %}

{%- if author_array_limit < author_array_size %}
and
<a class="author" title="
{%- for author in entry.author_array offset: author_array_limit -%}
{{author.last}}, {{author.first}}{% unless forloop.last %}, {% endunless %}
{%- endfor -%}
">{{ more_authors }} more author{% if more_authors > 1 %}s{% endif %}.</a>
{% endif %}

</div>

<!-- Journal/Book title and date -->
Expand Down