Feature: Map authors as tags in Vorname_Nachname format

- Added format_author_as_tag() function to convert author names to tag format
- Author names automatically added to tags with spaces replaced by underscores
- Example: 'Jörg Lohrer' → 'Jörg_Lohrer' tag
- Enables author filtering via WordPress tag taxonomy
- Updated documentation to reflect new author handling approach
- Version bump to 0.3.0
This commit is contained in:
Jörg Lohrer 2025-11-05 05:32:20 +01:00
parent 141b847e97
commit 85f58e2528
3 changed files with 72 additions and 3 deletions

View file

@ -39,6 +39,29 @@ def extract_frontmatter(markdown_content: str) -> tuple[Optional[Dict[str, Any]]
return None, markdown_content
def format_author_as_tag(author_name: str) -> str:
"""
Formatiert einen Autornamen als Tag im Format Vorname_Nachname
Args:
author_name: Autorenname (z.B. "Max Mustermann" oder "Max")
Returns:
Tag-formatierter Name (z.B. "Max_Mustermann")
"""
# Entferne führende/nachfolgende Leerzeichen
author_name = author_name.strip()
# Ersetze Leerzeichen durch Unterstriche
tag_name = author_name.replace(' ', '_')
# Entferne mehrfache Unterstriche
while '__' in tag_name:
tag_name = tag_name.replace('__', '_')
return tag_name
def extract_wordpress_metadata(frontmatter: Dict[str, Any],
default_author: str = "admin") -> Dict[str, Any]:
"""
@ -94,6 +117,10 @@ def extract_wordpress_metadata(frontmatter: Dict[str, Any],
elif isinstance(tags, str):
metadata['tags'] = [t.strip() for t in tags.split(',')]
# Initialisiere tags falls nicht vorhanden
if 'tags' not in metadata:
metadata['tags'] = []
# Kategorien extrahieren (falls vorhanden)
if 'categories' in frontmatter:
categories = frontmatter['categories']
@ -134,6 +161,15 @@ 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)
# Status extrahieren (falls vorhanden)
if 'status' in frontmatter:
metadata['status'] = frontmatter['status']