From 5d4dc2005caae740367f2a876936223d3dd4716b Mon Sep 17 00:00:00 2001 From: Hanzei Date: Wed, 10 Apr 2019 18:22:12 +0200 Subject: [PATCH] Fix NPE if projects or blog sections doesn't exist --- layouts/index.html | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/layouts/index.html b/layouts/index.html index 494e0d0..f18a170 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -42,13 +42,18 @@ {{ with .Site.GetPage "/home" }} - - {{ $blog := .Site.GetPage "/blog" }} - {{ $projects := .Site.GetPage "/projects" }} {{ $home := . }} + {{ $pages := .Resources.ByType "page" }} - {{ $pages := sort (.Resources.ByType "page" | append $blog | append $projects) "Params.weight" }} - {{ range $pages }} + {{ with .Site.GetPage "/blog" }} + {{ $pages = $pages | append . }} + {{ end }} + + {{ with .Site.GetPage "/projects" }} + {{ $pages = $pages | append . }} + {{ end }} + + {{ range sort $pages "Params.weight" }} {{ if ne .Name "contact.md" }} {{ if eq .File.Dir "projects/" }}