From 5fdc3e6ae9f688dfdbae8c99669ba5427b2dee78 Mon Sep 17 00:00:00 2001
From: Runxi Yu <me@runxiyu.org>
Date: Sun, 2 Mar 2025 09:11:17 +0800
Subject: Add actual navbar

---
 assets/style.css             | 33 ++++++++++++++++++++++++++++++++-
 layouts/_default/baseof.html | 24 ++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/assets/style.css b/assets/style.css
index 481e4af..949f7d1 100644
--- a/assets/style.css
+++ b/assets/style.css
@@ -33,15 +33,42 @@ a:link, a:visited {
 
 aside#sidebar {
 	position: fixed;
+	top: 0;
+	left: 0;
 	width: min(33%, 200px);
 	height: 100%;
 	background-color: var(--sidebar-bg);
 	overflow-y: auto;
+	padding: 0px 10px;
+	box-sizing: border-box;
+}
+
+aside#sidebar a:link,
+aside#sidebar a:visited {
+	text-decoration: none;
+	color: var(--fg);
+}
+
+
+aside#sidebar > ul > li:not(first-child) {
+	margin-top: 1rem;
+}
+
+aside#sidebar > ul {
+	list-style: none;
+}
+
+aside#sidebar ul {
+	padding-left: 1rem;
+}
+
+aside#sidebar > ul {
+	padding-left: 0rem;
 }
 
 div#main-and-footer {
 	margin-left: min(33%, 200px);
-	padding: 10px;
+	padding: 0px 10px;
 }
 
 main {
@@ -60,3 +87,7 @@ main:not(.wide) {
 		margin-left: 0px;
 	}
 }
+
+.nav-current {
+	font-weight: bold;
+}
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 33f8136..6f55b57 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -9,6 +9,30 @@
 	</head>
 	<body>
 		<aside id="sidebar">
+			<p style="text-align: center; font-weight: bold;">
+				<a href="/">{{ .Site.Title }}</a>
+			</p>
+			{{ $currentSection := .CurrentSection }}
+			<ul>
+				{{ range .Site.Sections }}
+					{{ if eq $currentSection . }}
+						<li class="nav-current"><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
+					{{ else }}
+						<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
+					{{ end }}
+					{{ if or (eq $currentSection .) ($currentSection.IsDescendant .) }}
+						<ul>
+							{{ range .Pages }}
+								{{ if eq $currentSection . }}
+									<li class="nav-current"><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
+								{{ else }}
+									<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
+								{{ end }}
+							{{ end }}
+						</ul>
+					{{ end }}
+				{{ end }}
+			</ul>	
 		</aside>
 		<div id="main-and-footer">
 			<main>
-- 
cgit v1.2.3