diff --git a/stsg/build.py b/stsg/build.py index 7c270fe..54ebe69 100644 --- a/stsg/build.py +++ b/stsg/build.py @@ -78,6 +78,23 @@ def convert_md(src: Path, dst: Path, context: Optional[Context] = None): with Path(folder_dst, "index.html").open("w") as f: f.write(full_page) + +class CustomLanguageCode: + def __init__(self, file: Path): + self.file: Path = file + + @property + def language_code(self) -> str: + return self.file.name.replace(".md", "") + + @property + def relative_url(self) -> str: + return str(self.file) + + def __repr__(self) -> str: + return f"{self.language_code}" + + def walk_directory(root): src_path = Path(SOURCE_DIRECTORY, root) dst_path = Path(DIST_DIRECTORY, root) @@ -95,7 +112,8 @@ def walk_directory(root): if current_name.endswith(".md"): convert_md(current_src, current_dst) - language_codes_found.append(current_name.replace(".md", "")) + + language_codes_found.append(CustomLanguageCode(Path(root, current_name))) continue if current_src.is_dir():