~captainepoch/blogtheme

a236c7d2c97fa8f4d3052ba6e924d14323fd29af — Adolfo Santiago 5 months ago 0d3209a master
Removed pagination, added Categories taxonomy
5 files changed, 30 insertions(+), 54 deletions(-)

M layouts/_default/list.html
M layouts/_default/section.html
A layouts/categories/terms.html
A layouts/partials/categories/content.html
D layouts/partials/pagination.html
M layouts/_default/list.html => layouts/_default/list.html +3 -3
@@ 1,13 1,13 @@
{{- define "main" -}}

<div>
  <h1>{{ .Title }}</h1>
	<h1>{{ .Title }}</h1>
</div>
{{- range .Paginator.Pages -}}
  <div class="article">
<div class="article">
	<span class="date">{{ .Date.Format "2006-01-02" }}</span>
	<a href="{{ .RelPermalink }}">{{- .Title -}}</a>
  </div>
</div>
{{- end -}}

{{- end -}}

M layouts/_default/section.html => layouts/_default/section.html +8 -9
@@ 1,14 1,13 @@
{{- define "main" -}}

<div>
  <h1>{{ .Title }}</h1>
	<h1>{{ .Title }}</h1>
</div>
<div>
  {{- .Content -}}
{{- range .Paginator.Pages -}}
<div class="article">
	<span class="date">{{ .Date.Format "2006-01-02" }}</span>
	<a href="{{ .RelPermalink }}">{{- .Title -}}</a>
</div>
<ul>
  {{- range .Paginator.Pages -}}
  <li>{{ with .Date }}{{ .Format "2006-01-02 15:04" }} - {{ end }}<a href="{{ .RelPermalink }}">{{ .Title }}</a>{{ with .Description }}: {{ . }}{{ end }}</li>
  {{- end -}}
</ul>
</main>
{{- end -}}

{{- end -}}

A layouts/categories/terms.html => layouts/categories/terms.html +3 -0
@@ 0,0 1,3 @@
{{ define "content" }}
{{ partial "categories/content.html" }}
{{ end }}

A layouts/partials/categories/content.html => layouts/partials/categories/content.html +16 -0
@@ 0,0 1,16 @@
{{ define "main" }}
<div class="content">
	<h1>{{ .Title }}</h1>
	{{ .Content }}
</div>

{{- range sort .Data.Terms -}}
<div>
	<a class="title is-5 is-size-6-mobile" href="{{ .Page.Permalink }}">
		{{ .Page.Title }}</a>
	{{ $pageCount := len .Pages }}
	{{ $pageCount }} post{{ if ne $pageCount 1}}s{{ end }}
</div>
{{- end -}}

{{ end }}

D layouts/partials/pagination.html => layouts/partials/pagination.html +0 -42
@@ 1,42 0,0 @@
{{/*
Taken from
https://code.luasoftware.com/tutorials/hugo/hugo-smart-pagination-template/
*/}}

{{ $pag := $.Paginator }}
{{ if gt $pag.TotalPages 1 }}
{{ $.Scratch.Set "dot_rendered" false }}
<nav aria-label="page navigation">
    <ul class="pagination">
        <!-- Don't show on 1st and 2nd page -->
        {{ if and (ne $pag.PageNumber 1) (ne $pag.PageNumber 2) }}
        <li class="page-item"><a href="{{ $pag.First.URL }}" rel="first" class="page-link">« First</a></li>
        {{ end }}

        {{ if $pag.HasPrev  }}
        <li class="page-item"><a href="{{ $pag.Prev.URL }}" rel="prev" class="page-link">‹ Prev</a></li>
        {{ end }}

        {{ range $pag.Pagers }}
            {{ if eq . $pag }} <!-- Current Page -->
            <li class="page-item active"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
            {{ else if and (ge .PageNumber (sub $pag.PageNumber 2)) (le .PageNumber (add $pag.PageNumber 2)) }}
            {{ $.Scratch.Set "dot_rendered" false }} <!-- Render prev 2 page and next 2 pages -->
            <li class="page-item"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
            {{ else if eq ($.Scratch.Get "dot_rendered") false }} <!-- render skip pages -->
            {{ $.Scratch.Set "dot_rendered" true }}
            <li class="page-item disabled"><a class="page-link">...</a></li>
            {{ end }}
        {{ end }}

        {{ if $pag.HasNext }}
        <li class="page-item"><a href="{{ $pag.Next.URL }}" rel="next" class="page-link">Next ›</a></li>
        {{ end }}

        <!-- Don't show on last and 2nd last page -->
        {{ if and (ne $pag.PageNumber $pag.TotalPages) ((ne $pag.PageNumber (sub $pag.TotalPages 1))) }}
        <li class="page-item"><a href="{{ $pag.Last.URL }}" rel="last" class="page-link">Last »</a></li>
        {{ end }}
    </ul>
</nav>
{{ end }}