feat: fallback to overview page
This commit is contained in:
parent
d019884dbe
commit
f84fb65aa7
@ -4,6 +4,8 @@ meow
|
||||
|
||||
## Usque de celebrabant puer
|
||||
|
||||
[{{index_page.title}}]({{index_page.url}})
|
||||
|
||||
Lorem markdownum, nec ora et vero me nec natae suadent. Nec damno ignorat
|
||||
propiore aliquid temptata decipienda habetur. Vulnera lacrimis aequoreo madidos,
|
||||
copia uvae, herbosaque quoque, per harenas, canos fui monstro Peleus.
|
||||
|
@ -13,7 +13,6 @@ import jinja2
|
||||
|
||||
from . import config
|
||||
|
||||
|
||||
def get_first_header_content(content, fallback: str = ""):
|
||||
soup = BeautifulSoup(content, 'html.parser')
|
||||
for level in range(1, 7):
|
||||
@ -131,15 +130,6 @@ class LanguageDict(dict):
|
||||
LANGUAGES = LanguageDict()
|
||||
|
||||
|
||||
class CrossArticleContext(TypedDict):
|
||||
slug: str
|
||||
title: str # from article is the same as slug
|
||||
url: str
|
||||
article_url: str # from article it is the same as url, from article_taanslation it links to the article
|
||||
date: str
|
||||
iso_date: str
|
||||
|
||||
|
||||
class ArticleTranslation:
|
||||
def __init__(self, file: Path, article: Article):
|
||||
self.file = file
|
||||
@ -181,6 +171,12 @@ class ArticleTranslation:
|
||||
]
|
||||
|
||||
def __init_content_context__(self):
|
||||
template = jinja2.Template(self.html_content)
|
||||
self.html_content = template.render({
|
||||
**CROSS_ARTICLE_CONTEXT,
|
||||
**TRANSLATED_CROSS_ARTICLE_CONTEXT[self.language_code],
|
||||
})
|
||||
|
||||
self.context["content"] = self.html_content
|
||||
self.context["preview"] = get_preview_text(html_string=self.html_content)
|
||||
|
||||
@ -295,8 +291,8 @@ class Article:
|
||||
|
||||
# GLOBALS
|
||||
logger = logging.getLogger("stsg.build")
|
||||
CROSS_ARTICLE_CONTEXT: Dict[str, CrossArticleContext] = {}
|
||||
TRANSLATED_CROSS_ARTICLE_CONTEXT: Dict[str, Dict[str, CrossArticleContext]] = defaultdict(dict)
|
||||
CROSS_ARTICLE_CONTEXT: Dict[str, Dict[str, Any]] = {}
|
||||
TRANSLATED_CROSS_ARTICLE_CONTEXT: Dict[str, Dict[str, Dict[str, Any]]] = defaultdict(dict)
|
||||
ARTICLE_LAKE: Dict[str, Article] = {}
|
||||
ARTICLE_REFERENCE_VALUES: DefaultDict[str, Dict[str, str]] = defaultdict(dict)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user