diff options
author | Maxim Zhiburt <zhiburt@gmail.com> | 2022-01-15 13:15:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-15 13:15:35 +0300 |
commit | 4db7d0e7b60a84cf4a17945e856df09159eef63d (patch) | |
tree | f71d13c9210647ed4e6e4020cec0fdb514f7348c | |
parent | bc4b2a2a22c69600bedf5a2220b4f58a876d553d (diff) |
Fix a nil pointer error (#71)
```log
failed to render pages: render of "page" failed: execute of template failed: template: myarchivetype/single.html:7:5: executing "myarchivetype/single.html" at <partial "classic_index.html" .>: error calling partial: execute of template failed: template: _internal/pagination.html:21:17: executing "_internal/pagination.html$htmltemplate_stateHTMLCmt" at <$page.Paginator.TotalPages>: error calling TotalPages: runtime error: invalid memory address or nil pointer dereference
```
-rwxr-xr-x | layouts/partials/classic_index.html | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/layouts/partials/classic_index.html b/layouts/partials/classic_index.html index 0813f46..5a4d567 100755 --- a/layouts/partials/classic_index.html +++ b/layouts/partials/classic_index.html @@ -4,26 +4,28 @@ <div id="content"> <div class="blog-index"> {{ $paginator := where site.RegularPages "Type" "in" site.Params.mainSections | .Paginate }} - {{ range $paginator.Pages }} - <article> - <!-- {{ .Scratch.Set "isHome" true }} --> - {{ partial "post_header.html" . }} - {{ if eq .Site.Params.truncate false }} - {{ .Content }} - {{ else if .Description }} - {{ .Description }} - <footer> - <a href="{{ .Permalink }}" rel="full-article">{{ with .Site.Params.continueReadingText }}{{ . | markdownify }}{{ else }}Read On →{{ end }}</a> - </footer> - {{ else }} - <p>{{ .Summary }}</p> - {{ if .Truncated }} - <footer> - <a href="{{ .Permalink }}" rel="full-article">{{ with .Site.Params.continueReadingText }}{{ . | markdownify }}{{ else }}Read On →{{ end }}</a> - </footer> + {{ if $paginator }} + {{ range $paginator.Pages }} + <article> + <!-- {{ .Scratch.Set "isHome" true }} --> + {{ partial "post_header.html" . }} + {{ if eq .Site.Params.truncate false }} + {{ .Content }} + {{ else if .Description }} + {{ .Description }} + <footer> + <a href="{{ .Permalink }}" rel="full-article">{{ with .Site.Params.continueReadingText }}{{ . | markdownify }}{{ else }}Read On →{{ end }}</a> + </footer> + {{ else }} + <p>{{ .Summary }}</p> + {{ if .Truncated }} + <footer> + <a href="{{ .Permalink }}" rel="full-article">{{ with .Site.Params.continueReadingText }}{{ . | markdownify }}{{ else }}Read On →{{ end }}</a> + </footer> + {{ end }} {{ end }} + </article> {{ end }} - </article> {{ end }} <!-- {{ template "_internal/pagination.html" . }} default pagination --> {{ partial "pagination.html" . }} <!-- use custom pagination --> @@ -31,4 +33,4 @@ {{ partial "sidebar.html" . }} <!-- sidebar --> </div> </div> -{{ partial "footer.html" . }} <!-- footer -->
\ No newline at end of file +{{ partial "footer.html" . }} <!-- footer --> |