mirror of
https://github.com/grey-cat-1908/website.git
synced 2024-11-11 18:57:26 +03:00
test base without content
This commit is contained in:
commit
dc6c82356d
5 changed files with 68 additions and 0 deletions
49
build.py
Normal file
49
build.py
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
import mistune
|
||||||
|
|
||||||
|
render = mistune.create_markdown(
|
||||||
|
plugins=['math', 'strikethrough', 'footnotes', 'table', 'url', 'task_lists', 'abbr', 'mark', 'subscript', 'spoiler']
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
shutil.rmtree("build")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
os.mkdir("build")
|
||||||
|
|
||||||
|
|
||||||
|
for filename in os.listdir("static"):
|
||||||
|
if len(filename.split(".")) == 1:
|
||||||
|
shutil.copytree(f"{os.getcwd()}/static/{filename}", f"{os.getcwd()}/build/{filename}")
|
||||||
|
else:
|
||||||
|
shutil.copy(f"{os.getcwd()}/static/{filename}", f"{os.getcwd()}/build/{filename}")
|
||||||
|
|
||||||
|
|
||||||
|
template_file = open('template.html', "r")
|
||||||
|
template_text = template_file.read()
|
||||||
|
template_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
def gen_file(directory):
|
||||||
|
file = open(directory, "r")
|
||||||
|
md_text = file.read()
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
return template_text.replace("{{%CONTENT%}}", render(md_text))
|
||||||
|
|
||||||
|
|
||||||
|
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'
|
||||||
|
|
||||||
|
file = open(f"{os.getcwd()}/build/{loc}", "a")
|
||||||
|
file.write(content)
|
||||||
|
file.close()
|
1
content/hoba/index.md
Normal file
1
content/hoba/index.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
poka
|
1
content/index.md
Normal file
1
content/index.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
privet
|
0
static/custom.css
Normal file
0
static/custom.css
Normal file
17
template.html
Normal file
17
template.html
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="/custom.css">
|
||||||
|
<title>Arbuz?</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
{{%CONTENT%}}
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
Loading…
Reference in a new issue