diff --git a/stsg/build.py b/stsg/build.py index bcc9548..8a0d00d 100644 --- a/stsg/build.py +++ b/stsg/build.py @@ -45,11 +45,17 @@ class TemplateContext: self.name = name self.context: Dict[str, Any] = {} + def __setitem__(self, key, value): + self.context[key] = value + class ArticleTranslation: def __init__(self, file: Path, article: Article): self.file = file self.article = article + + self.context = {} + self.language_code = self.file.stem self.article_content = self.file.read_text() @@ -75,15 +81,8 @@ class ArticleTranslation: self.title = get_first_header_content(self.article_content, fallback=self.language_name) - self.article_cards = "" - - def __init_values__(self): - article_card_strings = [] - for child in self.article.child_articles: - if self.language_code in child.article_translations_map: - article_card_strings.append(child.article_translations_map[self.language_code].get_article_card()) - - self.article_cards = "\n".join(article_card_strings) + def __init_context__(self): + pass def build(self): self.dist_path.mkdir(parents=True, exist_ok=True) @@ -104,7 +103,6 @@ class ArticleTranslation: "article_language_name": self.language_name, "article_language_code": self.language_code, "article_language_flag": self.language_flag, - "article_children_cards": self.article_cards, } if return_foreign_articles: @@ -176,7 +174,7 @@ class Article: self.article_cards = "\n".join(c.get_article_card() for c in self.child_articles) for at in self.article_translations: - at.__init_values__() + at.__init_context__() logger.info("found %s at %s with the translations %s", self.slug, ".".join(list(self.location_in_tree)), ",".join(self.article_translations_map.keys()))