From fb5ef9db01e7723bf14c1e269c9b97292b882d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80?= <61203964+grey-cat-1908@users.noreply.github.com> Date: Tue, 26 Dec 2023 10:01:18 +0300 Subject: [PATCH] ya hz zarabotaet ili net. ya s github'a redaktiruyu --- build.py | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/build.py b/build.py index d159d68..7b7d04d 100644 --- a/build.py +++ b/build.py @@ -34,16 +34,26 @@ def gen_file(directory): return template_text.replace("{{%CONTENT%}}", render(md_text)) +def go_through(directory): + for filename in os.listdir(directory): + if len(filename.split(".")) == 1: + content = gen_file(f"{os.getcwd()}/{directory}/{filename}/index.md") -for filename in os.listdir("content"): - if len(filename.split(".")) == 1: - content = gen_file(f"{os.getcwd()}/content/{filename}/index.md") - loc = f"{filename}/index.html" - os.makedirs(f'build/{filename}') - else: - content = gen_file(f"{os.getcwd()}/content/{filename}") - loc = filename.split(".")[0] + '.html' + fier = content[content.find('/'):] - file = open(f"{os.getcwd()}/build/{loc}", "a") - file.write(content) - file.close() \ No newline at end of file + if len(fier) != 0: fier += ""/ + + loc = f"{fier}{filename}/index.html" + os.makedirs(f'build/{fier}{filename}') + + go_through(directory + "/" + filename) + else: + # TODO: add support to ./././... + content = gen_file(f"{os.getcwd()}/content/{filename}") + loc = filename.split(".")[0] + '.html' + + file = open(f"{os.getcwd()}/build/{loc}", "a") + file.write(content) + file.close() + +go_through("content")