-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (26 loc) · 1.08 KB
/
main.py
File metadata and controls
36 lines (26 loc) · 1.08 KB
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
import yaml
from datetime import UTC, datetime
from pathlib import Path
from jinja2 import Environment, FileSystemLoader
with Path("portfolio.yaml").open(encoding="utf-8") as f:
data = yaml.safe_load(f)
# Add any extra context if needed
data["current_year"] = datetime.now(tz=UTC).year
for link in data.get("social_links"):
if not link.get("svg_path"):
continue
with Path(link["svg_path"]).open(encoding="utf-8") as svg_file:
link["svg_data"] = svg_file.read()
# Set up Jinja environment
env = Environment(loader=FileSystemLoader("."), autoescape=True)
index_template = env.get_template("templates/index_template.html")
resume_template = env.get_template("templates/resume_template.html")
# Render the template with the data
html_output = index_template.render(**data)
resume_output = resume_template.render(**data)
# Write the output to an HTML file
with Path("index.html").open("w", encoding="utf-8") as f:
f.write(html_output)
with Path("resume.html").open("w", encoding="utf-8") as f:
f.write(resume_output)
print("HTML file generated successfully!")