some refactoring
This commit is contained in:
parent
d43d6505b1
commit
2a7ebaa298
@ -215,11 +215,19 @@ class ArticleTranslation:
|
||||
|
||||
|
||||
class ArticleConfig(TypedDict):
|
||||
slug: str
|
||||
name: str
|
||||
datetime: str
|
||||
author: str
|
||||
|
||||
|
||||
class ArticleContext(TypedDict):
|
||||
slug: str
|
||||
name: str
|
||||
datetime: str
|
||||
author: str
|
||||
url: str
|
||||
|
||||
class Article:
|
||||
directory: Path
|
||||
|
||||
@ -235,6 +243,10 @@ class Article:
|
||||
logger.error("two articles have the same name at %s and %r", ARTICLE_LAKE[slug].directory, self.directory)
|
||||
exit(1)
|
||||
return slug
|
||||
|
||||
@cached_property
|
||||
def name(self) -> str:
|
||||
return self.config.get("name", self.slug)
|
||||
|
||||
article_path: List[Article]
|
||||
|
||||
@ -250,6 +262,9 @@ class Article:
|
||||
def dist_path(self) -> Path:
|
||||
return Path(config.setup.dist_directory, *self.slug_path[1:])
|
||||
|
||||
context: ArticleContext
|
||||
context_shared: Dict[str, Any]
|
||||
cross_article_context: Dict[str, Any]
|
||||
|
||||
def __init__(self, directory: Path, article_path: Optional[List[str]] = None, is_root: bool = False, parent: Optional[Article] = None):
|
||||
self.directory = directory
|
||||
@ -257,17 +272,12 @@ class Article:
|
||||
self.article_path: List[Article] = article_path or []
|
||||
self.article_path.append(self)
|
||||
|
||||
self.context: Dict[str, Any] = {}
|
||||
self.context_shared: Dict[str, Any] = {}
|
||||
self.context: ArticleContext = {}
|
||||
self.context_shared = {}
|
||||
self.cross_article_context = CROSS_ARTICLE_CONTEXT[self.slug] = {}
|
||||
|
||||
ARTICLE_LAKE[self.slug] = self
|
||||
|
||||
|
||||
print()
|
||||
print(self.slug_path)
|
||||
print(self.url)
|
||||
print(self.dist_path)
|
||||
|
||||
# build the tree
|
||||
self.child_articles: List[Article] = []
|
||||
self.article_translations_list: List[ArticleTranslation] = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user