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