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: