about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNgô Ngọc Đức Huy <huyngo@disroot.org>2021-06-08 22:11:32 +0700
committerNgô Ngọc Đức Huy <huyngo@disroot.org>2021-06-08 22:11:32 +0700
commita1a5e22cce5da1d3c2df63abc4c284a44dc065b5 (patch)
tree8f938365420f0e8811e00c41cb1779d2e3ea6982
parent627994a70827b75dc9e433c218b2305d6b8e6c5a (diff)
downloadblog-a1a5e22cce5da1d3c2df63abc4c284a44dc065b5.tar.gz
Add layout for comics
-rw-r--r--layouts/_default/single.html17
-rw-r--r--layouts/partials/comicNav.html40
2 files changed, 54 insertions, 3 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index b3783eb..2c87ed3 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -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" . }}
diff --git a/layouts/partials/comicNav.html b/layouts/partials/comicNav.html
new file mode 100644
index 0000000..2d8eeac
--- /dev/null
+++ b/layouts/partials/comicNav.html
@@ -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 }}