-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
49 lines (43 loc) · 1.42 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
pages = [
{ 'filename': 'content/index.html',
'output': 'docs/index.html',
'title': 'About Me',
},
{
'filename': 'content/resume.html',
'output': 'docs/resume.html',
'title': 'Resume',
},
{
'filename': 'content/education.html',
'output': 'docs/education.html',
'title': 'Education',
},
{
'filename': 'content/interests.html',
'output': 'docs/interests.html',
'title': 'Interests',
},
{
'filename': 'content/blog.html',
'output': 'docs/blog.html',
'title': 'Coding Journey Blog',
},
]
def apply_template(template, page_title, file_name):
index_content = open(file_name).read()
finished_index_page = template.replace('{{content}}', index_content)
finished_index_page = finished_index_page.replace('{{title}}', page_title)
return finished_index_page
def output_page(template,page):
file_name = page['filename']
page_output = page['output']
page_title = page['title']
output_html = apply_template(template, page_title, file_name)
open(page_output, 'w+').write(output_html)
def main():
template = open('templates/base.html').read()
for page in pages:
output_page(template, page)
if __name__ == "__main__":
main()