feat: writing article config values to class
This commit is contained in:
parent
d412d983bd
commit
83133218a4
@ -7,6 +7,8 @@ import markdown
|
||||
from typing import Optional, Union, Dict, Generator, List, DefaultDict
|
||||
from bs4 import BeautifulSoup
|
||||
from collections import defaultdict
|
||||
import toml
|
||||
import datetime
|
||||
|
||||
from . import config
|
||||
|
||||
@ -111,9 +113,14 @@ class ArticleTranslation:
|
||||
class ArticleOverview:
|
||||
def __init__(self, directory: Path, location_in_tree: Optional[List[str]] = None):
|
||||
self.directory = directory
|
||||
self.slug = self.directory.name
|
||||
|
||||
self.article_written = self.directory.stat().st_mtime
|
||||
article_config = {}
|
||||
if (self.directory / "index.toml").exists():
|
||||
article_config = toml.load(self.directory / "index.toml")
|
||||
|
||||
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)
|
||||
|
||||
self.location_in_tree: List[str] = location_in_tree or []
|
||||
self.location_in_tree.append(self.slug)
|
||||
|
Loading…
x
Reference in New Issue
Block a user