Skip to content

Commit

Permalink
move nav layout
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixMartel committed Jul 27, 2024
1 parent ef9c8cf commit 152f7cb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
9 changes: 5 additions & 4 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

main_layout = open("src/main_layout.html").read()
math_head = open("src/math_head.html").read()
nav_li = open("src/nav_li.html").read()
roll_li = open("src/roll_li.html").read()

def build_page(page_meta):
page, meta = page_meta
Expand All @@ -28,7 +30,7 @@ def build_page(page_meta):
page_out = page_out.replace("[[DESCRIPTION]]", description)
page_out = page_out.replace("[[DATE]]", f"{published_time}")
page_out = page_out.replace("[[URL]]", f"https://blog.lixtelnis.com/{page_name}/")
page_out = page_out.replace("[[SITEINDEX]]", site_index)
page_out = page_out.replace("[[NAVLI]]", site_index)
page_out = page_out.replace("[[BODY]]", body)
if needsmath:
page_out = page_out.replace("[[MATH]]", math_head)
Expand All @@ -42,12 +44,11 @@ def build_page(page_meta):
def build_index(page_metas):
page_metas = filter(lambda page_meta: not page_meta[1].get("ishome", False), page_metas)
page_metas = sorted(page_metas, key = lambda page_meta: page_meta[1].get("date", [0,0,0]), reverse=True)
index = '<ul>\n<h2>☰</h2>\n<div id="navhide"><li><a href="/">home</a></li>'
index = nav_li.replace("[[PAGENAME]]", 'home').replace("[[PAGELINK]]", '/')
for page, meta in page_metas:
page_dir = path.dirname(page)
page_name = path.basename(page_dir)
index += f'\n<li><a href="/{page_name}/">{page_name}</a></li>'
index += '\n</div></ul>'
index += '\n' + nav_li.replace("[[PAGENAME]]", page_name).replace("[[PAGELINK]]", f'/{page_name}/')
return index

def build_rss(page_metas):
Expand Down
7 changes: 6 additions & 1 deletion src/main_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@
<body>
<div id="sitelayout">
<nav>
[[SITEINDEX]]
<ul id="roll">
<h2></h2>
<div id="navhide">
[[NAVLI]]
</div>
</ul>
</nav>
<main>
<h1>[[TITLE]]</h1>
Expand Down
3 changes: 3 additions & 0 deletions src/nav_li.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<li>
<a href="[[PAGELINK]]">[[PAGENAME]]</a>
</li>
2 changes: 1 addition & 1 deletion src/pages/home/meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "Home",
"title": "home",
"description": "Félix Martel-Denis (lixtelnis)'s personal blog. So far it's about security bugs and ctfs.",
"ishome": true
}
Empty file added src/roll_li.html
Empty file.

0 comments on commit 152f7cb

Please sign in to comment.