~huyngo/huyngo.srht.site

a1a5e22cce5da1d3c2df63abc4c284a44dc065b5 — Ngô Ngọc Đức Huy 3 months ago 627994a
Add layout for comics
2 files changed, 54 insertions(+), 3 deletions(-)

M layouts/_default/single.html
A layouts/partials/comicNav.html
M layouts/_default/single.html => layouts/_default/single.html +14 -3
@@ 12,10 12,21 @@
		<h1 class="p-name post-title{{ if .Params.favorite }} favorite{{end}}{{ if .Params.draft }} draft{{end}}">{{ trim .Title  " " }}</h1>
	</header>
	<div class="content e-content">
		<!-- Comics-->
		{{ if in .Params.categories "comics" }}
		<center>
		{{ partial "comicNav.html" . }}
		{{ .Content }}
		{{ if in .Params.categories "book review" }}
		<hr>
		{{ i18n "BookShare" }}
		{{ partial "comicNav.html" . }}
		<center>
		{{ else }}
		<!-- normal content -->
		{{ .Content }}
			<!-- book reviews -->
			{{ if in .Params.categories "book review" }}
			<hr>
			{{ i18n "BookShare" }}
			{{ end }}
		{{ end }}
	</div>
	{{ partial "postInfo.html" . }}

A layouts/partials/comicNav.html => layouts/partials/comicNav.html +40 -0
@@ 0,0 1,40 @@
{{ $comics := ($.Site.GetPage "section" .Section).Pages.ByPublishDate }}
{{ $random := (shuffle (where (where .Site.RegularPages "Section" "comics") "Title" "!=" .Title )) }}

{{ if (eq .PrevInSection nil) }}
    <button disabled> First </button>
    <button disabled> Prev </button>
{{ end }}

{{ with .PrevInSection }}
  {{ range first 1 $comics }}
    <a href="{{ .Permalink }}">
      <button> First </button>
    </a>
  {{ end }}
  <a href="{{ .Permalink }}">
    <button> Prev </button>
  </a>
{{ end }}

{{ range first 1 $random }}
<a href="{{.Permalink}}">
  <button> Random </button>
</a>
{{ end }}

{{ with .NextInSection }}
  <a href="{{ .Permalink }}">
    <button> Next </button>
  </a>

  {{ range last 1 $comics }}
    <a href="{{ .Permalink }}">
      <button> Last </button>
    </a>
  {{ end }}
{{ end }}
{{ if (eq .NextInSection nil) }}
    <button disabled> Next </button>
    <button disabled> Last </button>
{{ end }}