]> git.dujemihanovic.xyz Git - dujemihanovic.xyz.git/commitdiff
Add recent posts to homepage
authorDuje Mihanović <duje.mihanovic@skole.hr>
Sat, 9 Sep 2023 16:17:07 +0000 (18:17 +0200)
committerDuje Mihanović <duje.mihanovic@skole.hr>
Sat, 9 Sep 2023 16:17:07 +0000 (18:17 +0200)
layouts/_default/baseof.html
layouts/index.html [new file with mode: 0644]
layouts/partials/head.html [new file with mode: 0644]
layouts/partials/meta.html [deleted file]

index c4616632466d6053a38a82904e2a87a520ce1285..0fb29c917a4f5bba4ed3e972fddc2f90333c2e48 100644 (file)
@@ -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 (file)
index 0000000..567a4ab
--- /dev/null
@@ -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 (file)
index 0000000..65d22e8
--- /dev/null
@@ -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 (file)
index 765d617..0000000
+++ /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>