Skip to content

Commit

Permalink
feature(material_blog): support email attribute from .authors.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Dec 2, 2024
1 parent c779b92 commit 117ddb4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion mkdocs_rss_plugin/integrations/theme_material_blog_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ def author_name_from_id(self, author_id: str) -> str:
and isinstance(self.blog_plugin_cfg.authors, dict)
):
if author_id in self.blog_plugin_cfg.authors:
return self.blog_plugin_cfg.authors.get(author_id).get("name")
author_metadata = self.blog_plugin_cfg.authors.get(author_id)
if "email" in self.blog_plugin_cfg.authors.get(author_id):
return f"{author_metadata.get('name')} ({author_metadata.get('email')})"
else:
return author_metadata.get("name")
else:
logger.error(
f"Author ID '{author_id}' is not part of known authors: "
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/docs/blog/.authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ authors:
name: Julien Moura
slug: julien-moura
url: https://geotribu.fr/team/julien-moura/
email: guts@gmail.com
2 changes: 1 addition & 1 deletion tests/fixtures/docs/blog/posts/firstpost.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
authors:
- alexvoss
- guts
date: 2023-10-11
categories:
- meta
Expand Down Expand Up @@ -29,4 +30,3 @@ pharetra, pellentesque risus in, consectetur urna. Nulla id enim facilisis
arcu tincidunt pulvinar. Vestibulum laoreet risus scelerisque porta congue.
In velit purus, dictum quis neque nec, molestie viverra risus. Nam pellentesque
tellus id elit ultricies, vel finibus erat cursus.

0 comments on commit 117ddb4

Please sign in to comment.