From: Duje Mihanović <duje.mihanovic@skole.hr>
Date: Sat, 9 Sep 2023 16:17:07 +0000 (+0200)
Subject: Add recent posts to homepage
X-Git-Url: http://git.dujemihanovic.xyz/browse.php?a=commitdiff_plain;h=83710f57f69cce08f7eb726cb8c4a3c55f4819b7;p=dujemihanovic.xyz.git

Add recent posts to homepage
---

diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index c461663..0fb29c9 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -1,13 +1,7 @@
 <!doctype html>
 <html lang="en">
 	<head>
-		{{ partial "meta.html" . }}
-		{{ $style := resources.Get "css/style.css" | resources.Minify }}
-		<link rel="stylesheet" href="{{ $style.RelPermalink }}?v=1.1.2">
-		{{ $index := $.Site.GetPage "/" }}
-		{{ range $index.AlternativeOutputFormats }}
-		{{ printf `<link rel="%s" type="%s" href="%s" title="%s">` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }}
-		{{ end }}
+		{{ partial "head.html" . }}
 	</head>
 
 	<body>
@@ -17,6 +11,7 @@
 			{{ end }}
 		</main>
 		<footer>
+			{{ $index := $.Site.GetPage "/" }}
 			{{ with $index.OutputFormats.Get "RSS" }}
 			<p><a href="{{ .RelPermalink }}">RSS feed</a> | This site is <a href="http://git.dujemihanovic.xyz/?p=dujemihanovic.xyz.git;a=summary">free software</a></p>
 			{{ end }}
diff --git a/layouts/index.html b/layouts/index.html
new file mode 100644
index 0000000..567a4ab
--- /dev/null
+++ b/layouts/index.html
@@ -0,0 +1,11 @@
+{{ define "main" }}
+{{ .Content }}
+<h1>Recent Posts</h1>
+<ul>
+	{{ range first 5 ($.Site.GetPage "/posts").Pages }}
+	<li><a href="{{ .RelPermalink }}">{{ .Title }}</a> - {{ .Date.Format "January 2, 2006" }}</li>
+	{{ end }}
+</ul>
+<ul style="list-style: none;"><li><a href="/posts">Read all the posts</a></li></ul>
+
+{{ end }}
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
new file mode 100644
index 0000000..65d22e8
--- /dev/null
+++ b/layouts/partials/head.html
@@ -0,0 +1,10 @@
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<meta name="description" content="Duje Mihanović's personal website">
+<title>{{ print .Page.Title }} | {{ print .Site.Title }}</title>
+{{ $style := resources.Get "css/style.css" | resources.Minify }}
+<link rel="stylesheet" href="{{ $style.RelPermalink }}?v=1.1.2">
+{{ $index := $.Site.GetPage "/" }}
+{{ range $index.AlternativeOutputFormats }}
+{{ printf `<link rel="%s" type="%s" href="%s" title="%s">` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }}
+{{ end }}
diff --git a/layouts/partials/meta.html b/layouts/partials/meta.html
deleted file mode 100644
index 765d617..0000000
--- a/layouts/partials/meta.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<meta charset="utf-8">
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<meta name="description" content="Duje Mihanović's personal website">
-<title>{{ print .Page.Title }} | {{ print .Site.Title }}</title>