Fixed display of author names on post_by... pages.

This commit is contained in:
Martin Danielsson 2016-02-24 10:41:33 +01:00
parent 93ea2bd689
commit 2ea0ba2437
2 changed files with 24 additions and 4 deletions

View file

@ -39,7 +39,17 @@ layout: default
{% endif %} {% endif %}
{% endif %} {% endif %}
--> -->
{% if post.author %}
{% assign author = site.data.authors[post.author] %}
{% if author %}
{% assign author_name = author.name %}
{% else %}
{% assign author_name = post.author %}
{% endif %}
{% else %}
{% assign author_name = site.title %}
{% endif %}
<div class="post-preview"> <div class="post-preview">
<a href="{{ post.url | prepend: site.baseurl }}"> <a href="{{ post.url | prepend: site.baseurl }}">
<h2 class="post-title"> {{ post.title }} <h2 class="post-title"> {{ post.title }}
@ -50,7 +60,7 @@ layout: default
</h3> </h3>
{% endif %} {% endif %}
</a> </a>
<p class="post-meta">Posted by {% if post.author %}{{ post.author }}{% else %}{{ site.title }}{% endif %} on {{ post.date | date: "%B %-d, %Y" }}</p> <p class="post-meta">Posted by {{ author_name }} on {{ post.date | date: "%B %-d, %Y" }}</p>
</div> </div>
<hr> <hr>

View file

@ -39,7 +39,17 @@ layout: default
{% endif %} {% endif %}
{% endif %} {% endif %}
--> -->
{% if post.author %}
{% assign author = site.data.authors[post.author] %}
{% if author %}
{% assign author_name = author.name %}
{% else %}
{% assign author_name = post.author %}
{% endif %}
{% else %}
{% assign author_name = site.title %}
{% endif %}
<div class="post-preview"> <div class="post-preview">
<a href="{{ post.url | prepend: site.baseurl }}"> <a href="{{ post.url | prepend: site.baseurl }}">
<h2 class="post-title"> {{ post.title }} <h2 class="post-title"> {{ post.title }}
@ -50,7 +60,7 @@ layout: default
</h3> </h3>
{% endif %} {% endif %}
</a> </a>
<p class="post-meta">Posted by {% if post.author %}{{ post.author }}{% else %}{{ site.title }}{% endif %} on {{ post.date | date: "%B %-d, %Y" }}</p> <p class="post-meta">Posted by {{ author_name }} on {{ post.date | date: "%B %-d, %Y" }}</p>
</div> </div>
<hr> <hr>