@@ -30,13 +31,17 @@

{{ title }}

-{% set author = authors %}
- {% if author and author.bio %} -
-

About {{author.name}}

-

{{author.bio|e}}

-
+ {% if author %} + {% for author_name in author %} + {% set author_data = SITE_AUTHORS | selectattr("name", "equalto", author_name) | first %} + {% if author_data and author_data.bio %} +
+

About {{author_data.name}}

+

{{author_data.bio|e}}

+ {% endif %} + {% endfor %} {% endif %} + {% endblock %} diff --git a/app.py b/app.py index f5ccb68..1fbc05d 100644 --- a/app.py +++ b/app.py @@ -31,6 +31,9 @@ app.site_vars["navigation"] = navigation app.site_vars["DATETIME_FORMAT"] = "%d %b %Y" app.site_vars["year"] = str(datetime.date.today().year) +app.site_vars["SITE_AUTHORS"] = json.loads( + pathlib.Path("_data/authors.json").read_text() +) @app.page diff --git a/scripts/check_author_list.py b/scripts/check_author_list.py index 8ba6db4..f02b2a4 100644 --- a/scripts/check_author_list.py +++ b/scripts/check_author_list.py @@ -17,6 +17,11 @@ def check_authors(): if not isinstance(author, list): print(f"Error: Author in {file_path} is not a list: {author}") failed = True + elif len(author) == 0: + print( + f"Error: Author list in {file_path} is empty. Remove the field if there is no author." + ) + failed = True except Exception as e: print(f"Error processing {file_path}: {e}") failed = True