from dataclasses import dataclass from pathlib import Path import re @dataclass class Article: path: str def read_contents(self) -> str: return Path(self.path).read_text() articles = [ Article( "./input/art-001.html", ), ] # generate slugs and read articles slugs = [] article_contents = [] for article in articles: contents = article.read_contents() id_match = re.search(r'

{title}

""" slugs.append(slug) # plug into template, write to index.html template = Path("./input/template.html").read_text() template = template.replace( "
", "\n".join(article_contents) ) template = template.replace("
", "\n".join(slugs)) with open("./index.html", "w", encoding="utf-8") as index_html: index_html.write(template)