From 7aa06b7f83b27a21cfc2f49f45d95603e8e4eb03 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Wed, 16 Apr 2025 13:15:27 +0200 Subject: [PATCH] feat: added meta context --- stsg/build.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stsg/build.py b/stsg/build.py index c85c7d4..f7228ba 100644 --- a/stsg/build.py +++ b/stsg/build.py @@ -86,19 +86,17 @@ class ArticleTranslation: self.priority = LANGUAGES[self.language_code]["priority"] + # TODO remove self.article_content = self.file.read_text() self.article_preview = self.article_content[:config.formatting.article_preview_length] + "..." if self.file.suffix == ".md": self.article_content = markdown.markdown(self.article_content) self.article_preview = markdown.markdown(self.article_preview) - self.location_in_tree = [self.language_code, *self.article.location_in_tree] - self.url = "/" + "/".join(self.location_in_tree) - self.dist_path = Path(config.setup.dist_directory, *self.location_in_tree) - self.title = get_first_header_content(self.article_content, fallback="") def __init_context__(self): + self.context["meta"] = self.article.context_meta self.context["language"] = LANGUAGES[self.language_code] def build(self): @@ -145,6 +143,9 @@ class Article: def __init__(self, directory: Path, location_in_tree: Optional[List[str]] = None, is_root: bool = False): self.directory = directory + self.context: Dict[str, Any] = {} + self.context_meta = self.context["meta"] = {} + article_config = {} if (self.directory / "index.toml").exists(): article_config = toml.load(self.directory / "index.toml")