Skip to content

Commit 28ebcbf

Browse files
squidfunkalexvoss
andcommitted
Added support for linking authors in blog posts
Co-authored-by: alexvoss <[email protected]>
1 parent 9c01605 commit 28ebcbf

File tree

6 files changed

+23
-4
lines changed

6 files changed

+23
-4
lines changed

docs/blog/.authors.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ authors:
33
name: Martin Donath
44
description: Creator
55
avatar: https://avatars.githubusercontent.com/u/932156
6+
url: https://github.com/squidfunk
67
alexvoss:
78
name: Alex Voss
89
description: Community support
910
avatar: https://avatars.githubusercontent.com/u/4134224
11+
url: https://github.com/alexvoss

docs/plugins/blog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,7 @@ The provided path is resolved from the [`docs` directory][mkdocs.docs_dir].
12051205
name: string # Author name
12061206
description: string # Author description
12071207
avatar: url # Author avatar
1208+
url: url # Author website URL
12081209
```
12091210

12101211
Note that `<author>` must be set to an identifier for associating authors

material/plugins/blog/author.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# IN THE SOFTWARE.
2020

2121
from mkdocs.config.base import Config
22-
from mkdocs.config.config_options import DictOfItems, SubConfig, Type
22+
from mkdocs.config.config_options import DictOfItems, Optional, SubConfig, Type
2323

2424
# -----------------------------------------------------------------------------
2525
# Classes
@@ -30,6 +30,7 @@ class Author(Config):
3030
name = Type(str)
3131
description = Type(str)
3232
avatar = Type(str)
33+
url = Optional(Type(str))
3334

3435
# -----------------------------------------------------------------------------
3536

material/templates/blog-post.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@
2727
<img src="{{ author.avatar }}" alt="{{ author.name }}">
2828
</span>
2929
<span class="md-profile__description">
30-
<strong>{{ author.name }}</strong><br>
30+
<strong>
31+
{% if author.url %}
32+
<a href="{{ author.url }}">{{ author.name }}</a>
33+
{% else %}
34+
{{ author.name }}
35+
{% endif %}
36+
</strong>
37+
<br>
3138
{{ author.description }}
3239
</span>
3340
</div>

src/plugins/blog/author.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# IN THE SOFTWARE.
2020

2121
from mkdocs.config.base import Config
22-
from mkdocs.config.config_options import DictOfItems, SubConfig, Type
22+
from mkdocs.config.config_options import DictOfItems, Optional, SubConfig, Type
2323

2424
# -----------------------------------------------------------------------------
2525
# Classes
@@ -30,6 +30,7 @@ class Author(Config):
3030
name = Type(str)
3131
description = Type(str)
3232
avatar = Type(str)
33+
url = Optional(Type(str))
3334

3435
# -----------------------------------------------------------------------------
3536

src/templates/blog-post.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@
5959
<img src="{{ author.avatar }}" alt="{{ author.name }}" />
6060
</span>
6161
<span class="md-profile__description">
62-
<strong>{{ author.name }}</strong><br />
62+
<strong>
63+
{% if author.url %}
64+
<a href="{{ author.url }}">{{ author.name }}</a>
65+
{% else %}
66+
{{ author.name }}
67+
{% endif %}
68+
</strong>
69+
<br />
6370
{{ author.description }}
6471
</span>
6572
</div>

0 commit comments

Comments
 (0)