Fix: Support multiple authors as tags

- 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'
This commit is contained in:
Jörg Lohrer 2025-11-05 05:40:46 +01:00
parent 85f58e2528
commit aa50145633

View file

@ -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: