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 2ca5cf0 commit 7f0cdd2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions material/templates/partials/source-file.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</span>
{% endmacro %}
{% macro render_authors(authors) %}
{% set git_authors = config.plugins.get("git-authors") %}
<span class="md-source-file__fact">
<span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
{% if authors | length == 1 %}
Expand All @@ -28,9 +29,13 @@
</span>
<nav>
{% for author in authors %}
{% if git_authors.config.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: 5 additions & 0 deletions src/templates/partials/source-file.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

<!-- Render authors -->
{% macro render_authors(authors) %}
{% set git_authors = config.plugins.get("git-authors") %}
<span class="md-source-file__fact">
<span class="md-icon" title="{{ lang.t('source.file.contributors') }}">
{% if authors | length == 1 %}
Expand All @@ -54,9 +55,13 @@
</span>
<nav>
{% for author in authors %}
{% if git_authors.config.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 7f0cdd2

Please sign in to comment.