feat: properly building additional keywords
This commit is contained in:
parent
dc61a7ee92
commit
c45cebe497
@ -4,8 +4,9 @@ import shutil
|
||||
from pathlib import Path
|
||||
import os
|
||||
import markdown
|
||||
from typing import Optional, Union, Dict, Generator, List
|
||||
from typing import Optional, Union, Dict, Generator, List, DefaultDict
|
||||
from bs4 import BeautifulSoup
|
||||
from collections import defaultdict
|
||||
|
||||
from .config import SOURCE_DIRECTORY, DIST_DIRECTORY, LANGUAGE_INFORMATION, ARTICLE_PREVIEW_LENGTH, DEFAULT_LANGUAGE
|
||||
|
||||
@ -157,10 +158,7 @@ class ArticleOverview:
|
||||
"article_overview_cards": self.overview_cards,
|
||||
}
|
||||
|
||||
def get_article_values(self, language_code: Optional[str] = None) -> Dict[str, str]:
|
||||
if language_code in self.article_translations_map:
|
||||
return self.article_translations_map[language_code].get_article_values()
|
||||
|
||||
def get_article_values(self) -> Dict[str, str]:
|
||||
res = {}
|
||||
for key, value in self._get_values().items():
|
||||
res[key + ":" + self.slug] = value
|
||||
@ -208,6 +206,7 @@ def copy_static():
|
||||
logger = logging.getLogger("stsg.build")
|
||||
TEMPLATE = Template(Path(SOURCE_DIRECTORY, "templates"))
|
||||
ARTICLE_LAKE: Dict[str, ArticleOverview] = {}
|
||||
ARTICLE_REFERENCE_VALUES: DefaultDict[str, Dict[str, str]] = defaultdict(dict)
|
||||
|
||||
def build():
|
||||
logger.info("building static page")
|
||||
@ -215,6 +214,12 @@ def build():
|
||||
copy_static()
|
||||
tree = ArticleOverview(directory=Path(SOURCE_DIRECTORY, "pages"))
|
||||
|
||||
print(ARTICLE_LAKE)
|
||||
# build article reverence values
|
||||
for article_overview in ARTICLE_LAKE.values():
|
||||
ARTICLE_REFERENCE_VALUES[None].update(article_overview.get_article_values())
|
||||
for language_code, at in article_overview.article_translations_map.items():
|
||||
ARTICLE_REFERENCE_VALUES[language_code].update(at.get_article_values())
|
||||
|
||||
print(ARTICLE_REFERENCE_VALUES)
|
||||
|
||||
tree.build()
|
Loading…
x
Reference in New Issue
Block a user