home page: add home page with the latest posts and photos

screenshots: update screenshot with new home page
This commit is contained in:
Marcin Mierzejewski 2020-05-03 11:38:44 +02:00
parent 49427a6f50
commit 512902121b
7 changed files with 91 additions and 21 deletions

View file

@ -3,12 +3,16 @@
<br/>
{{ .Content }}
<div class="posts-list">
{{ range sort .Data.Pages "Date" "desc" }}
{{ if not .Params.private }}
<div class="post-list-date">{{ .PublishDate.Format "Jan. 2, 2006" }}</div>
<h1><a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title }}</a></h1>
{{ .Summary }}
<div class="post">
<div class="date">{{ .PublishDate.Format "Jan. 2, 2006" }}</div>
<h1><a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title }}</a></h1>
{{ .Summary }}
</div>
{{ end }}
{{ end }}
</div>
{{ end }}

View file

@ -1,7 +1,40 @@
<head>
{{ range .Site.Params.navlinks }}
{{ if .home }}
<meta http-equiv="refresh" content="0; URL={{ .url | absURL }}" />
{{ define "main" }}
<h1>About</h1>
<p>
Console is a minimal, responsive and light theme for Hugo inspired by Linux console. <a href="/about/">(more)</a>
</p>
<br/>
<h1>Latest posts</h1>
<div class="posts-list">
{{ with .Site.GetPage "/posts" }}
{{ range first 3 ((where .Pages ".Params.private" "!=" true) sort .Data.Pages "Date" "desc")}}
<div class="post">
<div class="date">{{ .PublishDate.Format "Jan. 2, 2006" }}</div>
<h1><a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title }}</a></h1>
{{ .Summary }}
</div>
{{ end }}
{{ end }}
</div>
<h1>Latest photos</h1>
<div class="image-grid">
{{ with .Site.GetPage "/photos" }}
{{ range first 3 (sort .Data.Pages "Date" "desc")}}
<a href="{{ .Permalink }}" title="{{ .Title }}">
{{ $image := .Page.Resources.GetMatch .Params.image }}
{{ with $image }}
{{ $thumb := .Resize "400x" }}
<img src="{{ $thumb.RelPermalink }}" alt="{{ .Title }}" class="img-responsive">
{{end}}
</a>
{{ end }}
</head>
{{ end }}
</div>
{{ end }}