Fix commas in author list (#770)

This commit is contained in:
gzwongkk 2022-08-07 00:55:39 +08:00 committed by GitHub
parent 2186bddc0c
commit 58391d1dbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 53 deletions

View File

@ -247,8 +247,10 @@ scholar:
# Filter out certain bibtex entry keywords used internally from the bib output # Filter out certain bibtex entry keywords used internally from the bib output
filtered_bibtex_keywords: [abbr, abstract, arxiv, bibtex_show, html, pdf, selected, supp, blog, code, poster, slides, website, preview] filtered_bibtex_keywords: [abbr, abstract, arxiv, bibtex_show, html, pdf, selected, supp, blog, code, poster, slides, website, preview]
# Maximum number of authors to be shown, other authors will be visible on hover, leave blank to show all authors # Maximum number of authors to be shown for each publication (more authors are visible on click)
max_author_limit: 3 max_author_limit: 3 # leave blank to always show all authors
more_authors_animation_delay: 10 # more authors are revealed on click using animation; smaller delay means faster animation
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Responsive WebP Images # Responsive WebP Images

View File

@ -29,22 +29,22 @@
<div class="author"> <div class="author">
{% assign author_array_size = entry.author_array | size %} {% assign author_array_size = entry.author_array | size %}
{% assign author_array_limit = author_array_size %}
{%- if site.max_author_limit and author_array_size > site.max_author_limit %} {%- if site.max_author_limit and author_array_size > site.max_author_limit %}
{% assign author_array_limit = site.max_author_limit %} {% assign author_array_limit = site.max_author_limit %}
{% else %}
{% assign author_array_limit = author_array_size %}
{% endif %} {% endif %}
{%- for author in entry.author_array limit: author_array_limit -%} {%- for author in entry.author_array limit: author_array_limit -%}
{%- assign author_is_self = false -%} {%- assign author_is_self = false -%}
{%- if author.last == site.scholar.last_name %} {%- assign author_last_name = author.last | remove: "¶" | remove: "&" | remove: "*" | remove: "†" | remove: "^" -%}
{%- if author_last_name == site.scholar.last_name -%}
{%- if site.scholar.first_name contains author.first -%} {%- if site.scholar.first_name contains author.first -%}
{%- assign author_is_self = true -%} {%- assign author_is_self = true -%}
{%- endif -%} {%- endif -%}
{%- endif -%} {%- endif -%}
{%- assign coauthor_url = nil -%} {%- assign coauthor_url = nil -%}
{%- if site.data.coauthors[author.last] -%} {%- if site.data.coauthors[author_last_name] -%}
{%- for coauthor in site.data.coauthors[author.last] -%} {%- for coauthor in site.data.coauthors[author_last_name] -%}
{%- if coauthor.firstname contains author.first -%} {%- if coauthor.firstname contains author.first -%}
{%- assign coauthor_url = coauthor.url -%} {%- assign coauthor_url = coauthor.url -%}
{%- break -%} {%- break -%}
@ -52,53 +52,35 @@
{%- endfor -%} {%- endfor -%}
{%- endif -%} {%- endif -%}
{%- if forloop.length == 1 -%} {%- if forloop.length > 1 -%}
{%- if author_is_self %} {%- if forloop.first == false -%},&nbsp;{%- endif -%}
<em>{{author.last}}, {{author.first}}</em> {%- if forloop.last and author_array_limit == author_array_size -%}and&nbsp;{%- endif -%}
{%- else -%}
{{author.last}}, {{author.first}}
{%- endif -%} {%- endif -%}
{%- if author_is_self -%}
<em>{{author.first}} {{author.last}}</em>
{%- else -%} {%- else -%}
{%- unless forloop.last -%}
{% if author_is_self %}
<em>{{author.last}}, {{author.first}}</em>,&nbsp;
{%- else -%}
{% if coauthor_url -%}
<a href="{{coauthor_url}}">{{author.last}}, {{author.first}}</a>,&nbsp;
{%- else -%}
{{author.last}}, {{author.first}},&nbsp;
{%- endif -%}
{%- endif -%}
{%- else -%}
{%- if author_array_limit == author_array_size %} and {% endif %}
{% if author_is_self -%}
<em>{{author.last}}, {{author.first}}</em>
{% else -%}
{%- if coauthor_url -%} {%- if coauthor_url -%}
<a href="{{coauthor_url}}">{{author.last}}, {{author.first}}</a> <a href="{{coauthor_url}}">{{author.first}} {{author.last}}</a>
{% else -%} {%- else -%}
{{author.last}}, {{author.first}} {{author.first}} {{author.last}}
{%- endif -%} {%- endif -%}
{%- endif -%} {%- endif -%}
{%- endunless -%}
{%- endif -%}
{%- endfor %}
{% assign more_authors = author_array_size | minus: author_array_limit %}
{%- if more_authors > 0 %}
{% assign more_authors_hide = more_authors | append: " more author" %}
{% if more_authors > 1 %}
{% assign more_authors_hide = more_authors_hide | append: "s" %}
{% endif %}
{% assign more_authors_show = '' %}
{%- for author in entry.author_array offset: author_array_limit -%}
{% assign more_authors_show = more_authors_show | append: author.last | append: ", " | append: author.first %}
{% unless forloop.last %}
{% assign more_authors_show = more_authors_show | append: ",&nbsp;" %}
{% endunless %}
{%- endfor -%} {%- endfor -%}
and {%- assign more_authors = author_array_size | minus: author_array_limit -%}
{%- assign more_authors_hide = more_authors | append: " more author" -%}
{%- if more_authors > 0 -%}
{%- if more_authors > 1 -%}
{%- assign more_authors_hide = more_authors_hide | append: "s" -%}
{%- endif -%}
{%- assign more_authors_show = '' -%}
{%- for author in entry.author_array offset: author_array_limit -%}
{%- assign more_authors_show = more_authors_show | append: author.first | append: " " | append: author.last -%}
{%- unless forloop.last -%}
{%- assign more_authors_show = more_authors_show | append: ", " -%}
{%- endunless -%}
{%- endfor -%}
, and
<span <span
class="more-authors" class="more-authors"
title="click to view {{more_authors_hide}}" title="click to view {{more_authors_hide}}"
@ -112,10 +94,10 @@
if (++cursorPosition == more_authors_text.length){ if (++cursorPosition == more_authors_text.length){
clearInterval(textAdder); clearInterval(textAdder);
} }
}, 15); }, '{{site.more_authors_animation_delay}}');
" "
>{{more_authors_hide}}</span> >{{more_authors_hide}}</span>
{% endif %} {%- endif -%}
</div> </div>