Update build.py

This commit is contained in:
Виктор 2023-12-26 10:51:21 +03:00 committed by GitHub
parent ba528b140c
commit c0b815c2c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,23 +36,18 @@ def gen_file(directory):
def go_through(directory): def go_through(directory):
for filename in os.listdir(directory): for filename in os.listdir(directory):
if len(filename.split(".")) == 1: _, _, fier = directory.partition('/')
content = gen_file(f"{os.getcwd()}/{directory}/{filename}/index.md") if len(fier) != 0: fier += "/"
_, _, fier = directory.partition('/') if len(filename.split(".")) == 1:
if len(fier) != 0: fier += "/"
loc = f"{fier}{filename}/index.html"
os.makedirs(f'build/{fier}{filename}') os.makedirs(f'build/{fier}{filename}')
go_through(directory + "/" + filename) go_through(directory + "/" + filename)
else: else:
# TODO: add support to ./././... content = gen_file(f"{os.getcwd()}/{directory}/{filename}")
content = gen_file(f"{os.getcwd()}/content/{filename}") loc = fier + filename.split(".")[0] + '.html'
loc = filename.split(".")[0] + '.html'
file = open(f"{os.getcwd()}/build/{loc}", "a") file = open(f"{os.getcwd()}/build/{loc}", "a")
file.write(content) file.write(content)
file.close() file.close()
go_through("content") go_through("content")