feat: added meta context
This commit is contained in:
parent
f7a690405b
commit
7aa06b7f83
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user