Skip to content

Commit 117ddb4

Browse files
committed
feature(material_blog): support email attribute from .authors.yml
1 parent c779b92 commit 117ddb4

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

mkdocs_rss_plugin/integrations/theme_material_blog_plugin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ def author_name_from_id(self, author_id: str) -> str:
122122
and isinstance(self.blog_plugin_cfg.authors, dict)
123123
):
124124
if author_id in self.blog_plugin_cfg.authors:
125-
return self.blog_plugin_cfg.authors.get(author_id).get("name")
125+
author_metadata = self.blog_plugin_cfg.authors.get(author_id)
126+
if "email" in self.blog_plugin_cfg.authors.get(author_id):
127+
return f"{author_metadata.get('name')} ({author_metadata.get('email')})"
128+
else:
129+
return author_metadata.get("name")
126130
else:
127131
logger.error(
128132
f"Author ID '{author_id}' is not part of known authors: "

tests/fixtures/docs/blog/.authors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ authors:
1313
name: Julien Moura
1414
slug: julien-moura
1515
url: https://geotribu.fr/team/julien-moura/
16+

tests/fixtures/docs/blog/posts/firstpost.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
authors:
33
- alexvoss
4+
- guts
45
date: 2023-10-11
56
categories:
67
- meta
@@ -29,4 +30,3 @@ pharetra, pellentesque risus in, consectetur urna. Nulla id enim facilisis
2930
arcu tincidunt pulvinar. Vestibulum laoreet risus scelerisque porta congue.
3031
In velit purus, dictum quis neque nec, molestie viverra risus. Nam pellentesque
3132
tellus id elit ultricies, vel finibus erat cursus.
32-

0 commit comments

Comments
 (0)