Skip to content

Commit 3325a83

Browse files
Update tag_from_path.py
1 parent 09b6f99 commit 3325a83

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

plugins/tag_from_path.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1+
from typing import Any
2+
13
from pelican import signals
2-
from pelican.contents import Article
34
from pelican.generators import ArticlesGenerator
45

56

6-
def tag_from_path(article_generator: ArticlesGenerator, content: Article) -> None:
7-
if not hasattr(content, "tags"):
8-
content.tags = []
9-
content.tags.append(content.tag)
7+
def tag_from_path(article_generator: ArticlesGenerator, metadata: dict[str, Any]) -> None:
8+
metadata.setdefault("tags", []).append(metadata["tag"])
109

1110

1211
def register() -> None:
13-
signals.article_generator_write_article.connect(tag_from_path)
12+
signals.article_generator_context.connect(tag_from_path)

0 commit comments

Comments
 (0)