diff --git a/stsg/build.py b/stsg/build.py index c5361db..39bec57 100644 --- a/stsg/build.py +++ b/stsg/build.py @@ -85,6 +85,7 @@ class ArticleTranslation: self.dist_path = Path(config.setup.dist_directory, *self.location_in_tree) self.priority = LANGUAGES[self.language_code]["priority"] + self.real_language_code = LANGUAGES[self.language_code]["code"] # TODO remove self.article_content = self.file.read_text() @@ -191,16 +192,25 @@ class Article: at.__init_context__() self.__init_context__() + import json + print(json.dumps(self.context, indent=4)) + def __init_context__(self): self.context["url"] = self.url self.context_meta["slug"] = self.slug - modified_at = datetime.fromisoformat(article_config["datetime"]) if "datetime" in article_config else datetime.fromtimestamp(self.directory.stat().st_mtime) + modified_at = datetime.fromisoformat(self.config["datetime"]) if "datetime" in self.config else datetime.fromtimestamp(self.directory.stat().st_mtime) self.context_meta["date"] = modified_at.strftime(config.formatting.datetime_format) self.context_meta["iso_date"] = modified_at.isoformat() + # add translations to context + translation_list = self.context["translations"] = [] + for article_translation in self.article_translations_list: + self.context[article_translation.real_language_code] = article_translation.context + translation_list.append(article_translation.context) + def build(self): @@ -264,4 +274,4 @@ def build(): ARTICLE_REFERENCE_VALUES[language_code].update(at.get_article_values()) logger.info("writing page tree...") - tree.build() \ No newline at end of file + # tree.build() \ No newline at end of file