Reversed List Layout Except Poem Sections

I have this code on my list.html layout →

<!doctype html>
<html lang="en">

{{ partial "head.html" . }}
<body>

{{ partial "header.html" . }}
<main class="main">

<div class="title">
<a href="{{ .Permalink }}">
<div class="center">
<h1>{{ .Title }}</h1>
</div>
</a>
</div>
{{ range (.Paginate (.Pages).Reverse).Pages }}
<article class="list">
<a href="{{ .Permalink }}">
<div class="list-header">
<h2>{{ .Title }}</h2>
</div>
<div class="list-content">
{{ if eq .Section "quote" }}
<blockquote>
<h3>
{{ .Summary | truncate 80 }}
</h3>
</blockquote>
{{ else }}
<h3>
{{ .Summary | truncate 80 }}
</h3>
{{ end }}
</div>
</a>
</article>
{{ end }}
<div class="center">
<form method="get" action="https://google.com/search" target="_blank">
<input class="search" type="hidden" name="q" value="site:angora.me">
<input id="search" class="search" type="text" name="q" placeholder="Search? Type And Enter!">
<label for="search" class="hollow">_</label>
</form>
</div>

<div class="pagination">
<a class="prev" href="{{ if .Paginator.HasPrev }}{{ .Paginator.Prev.URL | absURL }}{{ else }}#{{ end }}">« Prev</a>
<div id="mode" class="heartbeat">
<div id="darkBtn"><img alt="{{ .Site.Title }}" src="{{ .Site.Params.Cdn }}/bayuangora.svg"></div>
<div id="lightBtn" class="hidden"><img alt="{{ .Site.Title }}" src="{{ .Site.Params.Cdn }}/bayuangora.svg"></div>
</div>
<a class="next" href="{{ if .Paginator.HasNext }}{{ .Paginator.Next.URL | absURL }}{{ else }}#{{ end }}">Next »</a>
</div>

</main>

{{ partial "footer.html" . }}
</body>

</html>

I use {{ range (.Paginate (.Pages).Reverse).Pages }} because I need all of sections articles reversed, except POEM sections.

I tried this code but it doesn’t works →

<!doctype html>
<html lang="en">

{{ partial "head.html" . }}
<body>

{{ partial "header.html" . }}
<main class="main">

<div class="title">
<a href="{{ .Permalink }}">
<div class="center">
<h1>{{ .Title }}</h1>
</div>
</a>
</div>
{{ if eq .Section "poem" }}
{{ range (.Paginate (.Pages)).Pages }}
{{ else }}
{{ range (.Paginate (.Pages).Reverse).Pages }}
<article class="list">
<a href="{{ .Permalink }}">
<div class="list-header">
<h2>{{ .Title }}</h2>
</div>
<div class="list-content">
{{ if eq .Section "quote" }}
<blockquote>
<h3>
{{ .Summary | truncate 80 }}
</h3>
</blockquote>
{{ else }}
<h3>
{{ .Summary | truncate 80 }}
</h3>
{{ end }}
</div>
</a>
</article>
{{ end }}
<div class="center">
<form method="get" action="https://google.com/search" target="_blank">
<input class="search" type="hidden" name="q" value="site:angora.me">
<input id="search" class="search" type="text" name="q" placeholder="Search? Type And Enter!">
<label for="search" class="hollow">_</label>
</form>
</div>

<div class="pagination">
<a class="prev" href="{{ if .Paginator.HasPrev }}{{ .Paginator.Prev.URL | absURL }}{{ else }}#{{ end }}">« Prev</a>
<div id="mode" class="heartbeat">
<div id="darkBtn"><img alt="{{ .Site.Title }}" src="{{ .Site.Params.Cdn }}/bayuangora.svg"></div>
<div id="lightBtn" class="hidden"><img alt="{{ .Site.Title }}" src="{{ .Site.Params.Cdn }}/bayuangora.svg"></div>
</div>
<a class="next" href="{{ if .Paginator.HasNext }}{{ .Paginator.Next.URL | absURL }}{{ else }}#{{ end }}">Next »</a>
</div>

</main>

{{ partial "footer.html" . }}
</body>

</html>

How to fix this?

{{ $pages := .Pages.Reverse}}
{{ if eq .Section "poem" }}
  {{ $pages = .Pages }}
{{ end }}

{{ range (.Paginate $pages).Pages }}
  <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}

{{ template "_internal/pagination.html" . }}
1 Like