Skip to content

Commit 3d307ec

Browse files
committed
Update templates to handle missing author field gracefully
1 parent e80c83a commit 3d307ec

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

_layouts/blog-list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2><a href="{{ page }}.html">
1212
{% if page.description %}
1313
<p>{{page.description}}</p>
1414
{% endif %}
15-
<small>{{page.author | join(", ")}} - <strong>{{page.date | format_datetime}}</strong></small>
15+
<small>{% if page.author %}{{page.author | join(", ")}} - {% endif %}<strong>{{page.date | format_datetime}}</strong></small>
1616
</div>
1717
</article>
1818
{% endfor %}

_layouts/post.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
<header class="post-header">
1616
<h1 class="post-title p-name" itemprop="name headline">{{ title }}</h1>
1717
<p class="post-meta">
18+
{% if author %}
1819
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
1920
{% for person in author %}
2021
<span class="p-author h-card" itemprop="name">{{ person }}</span>
2122
{% if not loop.last %}, {% endif %}
2223
{% endfor %}
2324
</span>
24-
25+
{% endif %}
2526
</p>
2627
</header>
2728
<div class="post-content e-content" itemprop="articleBody">
@@ -31,6 +32,7 @@ <h1 class="post-title p-name" itemprop="name headline">{{ title }}</h1>
3132
</section>
3233

3334
<section>
35+
{% if author %}
3436
{% for author_name in author %}
3537
{% set author_data = SITE_AUTHORS | selectattr("name", "equalto", author_name) | first %}
3638
{% if author_data and author_data.bio %}
@@ -39,6 +41,7 @@ <h3>About {{author_data.name}}</h3>
3941
<p>{{author_data.bio|e}}</p>
4042
{% endif %}
4143
{% endfor %}
44+
{% endif %}
4245
</section>
4346

4447
{% endblock %}

0 commit comments

Comments
 (0)