diff options
author | Hanzei <hanzei@mailbox.org> | 2019-04-10 19:22:12 +0300 |
---|---|---|
committer | Hanzei <hanzei@mailbox.org> | 2019-04-10 19:22:12 +0300 |
commit | 5d4dc2005caae740367f2a876936223d3dd4716b (patch) | |
tree | fe82486b1d50b8fd012262b878c71b64e8661037 /layouts | |
parent | 5712e49125c893d18e6fea8d10494bacdc420c96 (diff) |
Fix NPE if projects or blog sections doesn't exist
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/index.html | 15 |
1 files 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 @@ </section> <!-- Done with Hero --> {{ with .Site.GetPage "/home" }} - - {{ $blog := .Site.GetPage "/blog" }} - {{ $projects := .Site.GetPage "/projects" }} {{ $home := . }} + {{ $pages := .Resources.ByType "page" }} + + {{ with .Site.GetPage "/blog" }} + {{ $pages = $pages | append . }} + {{ end }} + + {{ with .Site.GetPage "/projects" }} + {{ $pages = $pages | append . }} + {{ end }} - {{ $pages := sort (.Resources.ByType "page" | append $blog | append $projects) "Params.weight" }} - {{ range $pages }} + {{ range sort $pages "Params.weight" }} {{ if ne .Name "contact.md" }} {{ if eq .File.Dir "projects/" }} <!-- Now for some cool projects --> |