feat: initializing location
This commit is contained in:
parent
7aa06b7f83
commit
cf8e2955c2
@ -78,7 +78,7 @@ class ArticleTranslation:
|
||||
|
||||
self.context: Dict[str, Any] = {}
|
||||
|
||||
# setting the location of the article translation
|
||||
# initializing the location of the article translation
|
||||
self.language_code = stem_to_language_code(self.file.stem)
|
||||
self.location_in_tree = [self.language_code, *self.article.location_in_tree]
|
||||
self.url = "/" + "/".join(self.location_in_tree)
|
||||
@ -146,13 +146,16 @@ class Article:
|
||||
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")
|
||||
# initializing the config values of the article
|
||||
config_file = self.directory / "index.toml"
|
||||
self.config = toml.load(config_file) if config_file.exists() else {}
|
||||
|
||||
self.slug = article_config.get("name", self.directory.name)
|
||||
|
||||
self.article_written = datetime.datetime.fromisoformat(article_config["datetime"]) if "datetime" in article_config else datetime.datetime.fromtimestamp(self.directory.stat().st_mtime)
|
||||
# initializing the location and slug of the article
|
||||
self.slug = self.config.get("name", self.directory.name)
|
||||
if self.slug in ARTICLE_LAKE:
|
||||
logger.error("two articles have the same name at %s and %r", ARTICLE_LAKE[self.slug].directory, self.directory)
|
||||
exit(1)
|
||||
ARTICLE_LAKE[self.slug] = self
|
||||
|
||||
self.location_in_tree: List[str] = location_in_tree or []
|
||||
if not is_root:
|
||||
@ -160,10 +163,10 @@ class Article:
|
||||
self.url = "/" + "/".join(self.location_in_tree)
|
||||
self.dist_path = Path(config.setup.dist_directory, *self.location_in_tree)
|
||||
|
||||
if self.slug in ARTICLE_LAKE:
|
||||
logger.error("two articles have the same name at %s and %r", ARTICLE_LAKE[self.slug].directory, self.directory)
|
||||
exit(1)
|
||||
ARTICLE_LAKE[self.slug] = self
|
||||
|
||||
|
||||
self.article_written = datetime.datetime.fromisoformat(article_config["datetime"]) if "datetime" in article_config else datetime.datetime.fromtimestamp(self.directory.stat().st_mtime)
|
||||
|
||||
|
||||
self.child_articles: List[Article] = []
|
||||
self.article_translations: List[ArticleTranslation] = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user