Skip to content

Commit

Permalink
Only show authors' email addresses if so configured in git-authors
Browse files Browse the repository at this point in the history
Honour the git-authors plugin's setting to render the authors' names
as links pointing to their email address:

* If the git-authors plugin is enabled and its show_email_address
  option is not set, or is set to true, render the author's name as a
  "mailto:" link.
* If the git-authors plugin is enabled and its show_email_address
  option is set to false, render the author's name in plain text with
  no link.
* If the git-authors plugin is not enabled (or not installed), don't
  show author information.
  • Loading branch information
fghaas committed Dec 12, 2023
1 parent 9e52d1c commit b2b6f55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions material/templates/partials/source-file.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
</span>
{% endmacro %}
{% macro render_authors(authors) %}
{% set git_authors = config.plugins.get("git-authors") %}
{% set show_email_address = git_authors.config.show_email_address %}
<span class="md-source-file__fact">
<span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
{% if authors | length == 1 %}
Expand All @@ -28,9 +30,7 @@
</span>
<nav>
{% for author in authors %}
<a href="mailto:{{ author.email }}">
{{- author.name -}}
</a>
{%- if show_email_address %}<a href="mailto:{{ author.email }}">{{- author.name -}}</a>{%- else -%}{{- author.name -}}{% endif -%}
{%- if loop.revindex > 1 %}, {% endif -%}
{% endfor %}
</nav>
Expand Down
5 changes: 3 additions & 2 deletions src/templates/partials/source-file.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@

<!-- Render authors -->
{% macro render_authors(authors) %}
{% set show_email_address = page.repo().config("show_email_address") %}
{% set git_authors = config.plugins.get("git-authors") %}
{% set show_email_address = git_authors.config.show_email_address %}
<span class="md-source-file__fact">
<span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
{% if authors | length == 1 %}
Expand All @@ -55,7 +56,7 @@
</span>
<nav>
{% for author in authors %}
{%- if show_email_address %}<a href="mailto:{{ author.email }}">{{- author.name -}}</a>{% else -%}{{- author.name -}}{% endif -%}
{%- if show_email_address %}<a href="mailto:{{ author.email }}">{{- author.name -}}</a>{%- else -%}{{- author.name -}}{% endif -%}
{%- if loop.revindex > 1 %}, {% endif -%}
{% endfor %}
</nav>
Expand Down

0 comments on commit b2b6f55

Please sign in to comment.