Fix NPE if projects or blog sections doesn't exist (#148)

See https://github.com/victoriadotdev/hugo-theme-introduction/pull/143#issuecomment-481732990
This commit is contained in:
Hanzei 2019-04-10 19:04:50 +02:00 committed by GitHub
commit 76123d6853
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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" }}
{{ $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/" }}
<!-- Now for some cool projects -->