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:
parent
85f58e2528
commit
aa50145633
1 changed files with 52 additions and 8 deletions
|
|
@ -161,14 +161,58 @@ def extract_wordpress_metadata(frontmatter: Dict[str, Any],
|
||||||
if 'author' not in metadata:
|
if 'author' not in metadata:
|
||||||
metadata['author'] = default_author
|
metadata['author'] = default_author
|
||||||
|
|
||||||
# Autor als Tag hinzufügen (Format: Vorname_Nachname)
|
# Alle Autoren als Tags hinzufügen (Format: Vorname_Nachname)
|
||||||
if metadata.get('author'):
|
# Sammle alle Autoren aus verschiedenen Quellen
|
||||||
author_tag = format_author_as_tag(metadata['author'])
|
all_authors = []
|
||||||
# Füge Autor-Tag zu den Tags hinzu, falls noch nicht vorhanden
|
|
||||||
if author_tag and author_tag not in metadata.get('tags', []):
|
# Aus direktem author-Feld
|
||||||
if 'tags' not in metadata:
|
if 'author' in frontmatter:
|
||||||
metadata['tags'] = []
|
author = frontmatter['author']
|
||||||
metadata['tags'].append(author_tag)
|
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)
|
# Status extrahieren (falls vorhanden)
|
||||||
if 'status' in frontmatter:
|
if 'status' in frontmatter:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue