Skip to content

Commit 7e4e39e

Browse files
committed
feat: support multiple authors
Signed-off-by: Lachezar Lechev <[email protected]>
1 parent f42539c commit 7e4e39e

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

content/blog/YYYY-MM-DD-Draft-blog-post.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ description = "Description of your blog post for the blog listing"
77
# The date is set by the filename but we need to use it here,
88
# as the file does not contain a valid date "YYYY-MM-DD"
99
date = "2022-01-01"
10+
# Is it still a draft?
11+
draft = true
1012
[extra]
11-
author = "The AeroRust community"
13+
14+
[[extra.author]]
15+
name = "The AeroRust community"
1216
# The author's twitter account
1317
twitter = "AeroRust"
1418
# The author's Github account
1519
github = "AeroRust"
16-
# Is it still a draft?
17-
draft = true
1820
+++
1921

2022
Text of your blog

templates/base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% import "macros/meta.html" as meta_macros -%}
2+
{% import "blog/authors.html" as authors -%}
23
<!DOCTYPE html>
34
<html lang="en">
45

templates/blog.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ <h3 class="pb-4 mb-4 border-bottom">
2121
{% for post in paginator.pages -%}
2222
<article class="blog-post">
2323
<h2 class="blog-post-title mb-1"><a href="{{ post.permalink | safe }}">{{ post.title }}</a></h2>
24-
<p class="blog-post-meta">{{ post.date | date(format="%B %e, %Y") }} by {{ post.extra.author }} ( <a
25-
href="https://twitter.com/{{ post.extra.twitter}}" target="_blank"
26-
><i class="bi bi-twitter pe-1"></i>@{{ post.extra.twitter }}</a> | <a
27-
href="https://github.com/{{ post.extra.github}}" target="_blank"
28-
><i class="bi bi-github pe-1"></i>{{ post.extra.github }}</a> )</p>
24+
<p class="blog-post-meta">{{ post.date | date(format="%B %e, %Y") }} by
25+
{{ authors::comma_separated(authors=post.extra.author) }}
26+
{# {% for author in post.extra.author %}
27+
{{ author.name }} ( <a href="https://twitter.com/{{ author.twitter}}" target="_blank">
28+
<i class="bi bi-twitter pe-1"></i>@{{ author.twitter }}</a> |
29+
<a href="https://github.com/{{ author.github}}" target="_blank"><i class="bi bi-github pe-1"></i>{{ author.github }}</a> ) {% if not loop.last %},{% endif %}
30+
31+
{% endfor %} #}
32+
</p>
2933

3034
<p>{{ post.description }}</p>
3135

templates/blog/authors.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{% macro comma_separated(authors) %}
2+
{% for author in authors %}
3+
{{ author.name }} ( <a href="https://twitter.com/{{ author.twitter}}" target="_blank">
4+
<i class="bi bi-twitter pe-1"></i>@{{ author.twitter }}</a> |
5+
<a href="https://github.com/{{ author.github}}" target="_blank"><i class="bi bi-github pe-1"></i>{{ author.github }}</a>
6+
) {% if not loop.last %},{% endif %}
7+
8+
{% endfor %}
9+
{% endmacro comma_separated %}

templates/blog_post.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
{% block title %}{{ page.title }}{% endblock %}
44

55
{% block content %}
6+
67
<div class="row gx-5 mt-3">
78
<div class="col-md-8">
89
<article class="blog-post">
910
<h1 class="blog-post-title pb-4 mb-4 fst-italic border-bottom">{{ page.title }}</h1>
10-
<p class="blog-post-meta">{{ page.date | date(format="%B %e, %Y") }} by {{ page.extra.author }} ( <a href="https://twitter.com/{{ page.extra.twitter}}" target="_blank"><i class="bi bi-twitter pe-1"></i>@{{ page.extra.twitter}}</a> | <a
11-
href="https://github.com/{{ page.extra.github}}" target="_blank"
12-
><i class="bi bi-github pe-1"></i>{{ page.extra.github }}</a> )</p>
13-
11+
<p class="blog-post-meta">{{ page.date | date(format="%B %e, %Y") }} by
12+
{{ authors::comma_separated(authors=page.extra.author) }}
13+
</p>
1414
{{ page.content | safe }}
1515
</article>
1616
</div>

0 commit comments

Comments
 (0)