From aa50145633ffa4617a576203a2569ef44f8113c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lohrer?= Date: Wed, 5 Nov 2025 05:40:46 +0100 Subject: [PATCH] Fix: Support multiple authors as tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Previously only first author from list was converted to tag - Now collects all authors from all sources (author, #staticSiteGenerator.author, #commonMetadata.creator) - Handles both single authors and author lists - Removes duplicates if same author appears in multiple sources - All authors are added as individual tags in Vorname_Nachname format - Example: ['Florian Mayrhofer', 'Gina Buchwald-Chassée'] → tags 'Florian_Mayrhofer', 'Gina_Buchwald-Chassée' --- markdown_parser.py | 60 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/markdown_parser.py b/markdown_parser.py index 18a15be..6bf6421 100644 --- a/markdown_parser.py +++ b/markdown_parser.py @@ -161,14 +161,58 @@ def extract_wordpress_metadata(frontmatter: Dict[str, Any], if 'author' not in metadata: metadata['author'] = default_author - # Autor als Tag hinzufügen (Format: Vorname_Nachname) - if metadata.get('author'): - author_tag = format_author_as_tag(metadata['author']) - # Füge Autor-Tag zu den Tags hinzu, falls noch nicht vorhanden - if author_tag and author_tag not in metadata.get('tags', []): - if 'tags' not in metadata: - metadata['tags'] = [] - metadata['tags'].append(author_tag) + # Alle Autoren als Tags hinzufügen (Format: Vorname_Nachname) + # Sammle alle Autoren aus verschiedenen Quellen + all_authors = [] + + # Aus direktem author-Feld + if 'author' in frontmatter: + author = frontmatter['author'] + if isinstance(author, list): + all_authors.extend(author) + elif isinstance(author, str): + all_authors.append(author) + + # Aus #staticSiteGenerator + if isinstance(frontmatter.get('#staticSiteGenerator'), dict): + static_gen = frontmatter['#staticSiteGenerator'] + if 'author' in static_gen: + author = static_gen['author'] + if isinstance(author, list): + all_authors.extend(author) + elif isinstance(author, str): + all_authors.append(author) + + # Aus #commonMetadata.creator + if isinstance(frontmatter.get('#commonMetadata'), dict): + common = frontmatter['#commonMetadata'] + if 'creator' in common: + creator = common['creator'] + if isinstance(creator, list): + for c in creator: + if isinstance(c, dict): + given = c.get('givenName', '') + family = c.get('familyName', '') + full_name = f"{given} {family}".strip() + if full_name: + all_authors.append(full_name) + elif isinstance(creator, dict): + given = creator.get('givenName', '') + family = creator.get('familyName', '') + full_name = f"{given} {family}".strip() + if full_name: + all_authors.append(full_name) + + # Duplikate entfernen und als Tags hinzufügen + seen_authors = set() + for author_name in all_authors: + if author_name and author_name not in seen_authors: + seen_authors.add(author_name) + author_tag = format_author_as_tag(author_name) + if author_tag and author_tag not in metadata.get('tags', []): + if 'tags' not in metadata: + metadata['tags'] = [] + metadata['tags'].append(author_tag) # Status extrahieren (falls vorhanden) if 'status' in frontmatter: