about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2022-06-28 01:08:31 +0900
committerNguyễn Gia Phong <mcsinyx@disroot.org>2022-06-28 01:08:31 +0900
commitb2195e98804c404e80a5cc4e649d4e59f0d40be7 (patch)
treeaaedb7e0b7ef2ab5a9e35a17f543964a88b2c024
parentdd5e634482c2747d4514b784ec8dded9c7fa29cf (diff)
downloadphylactery-b2195e98804c404e80a5cc4e649d4e59f0d40be7.tar.gz
Fix adjacent links
-rw-r--r--README.md2
-rw-r--r--main.go13
-rw-r--r--templates/archive.html10
3 files changed, 18 insertions, 7 deletions
diff --git a/README.md b/README.md
index 5eb8e9c..bf38a86 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Phylactery is a web server rendering comic books directly from ZIP archives.
 
 ## Hacking
 
-    PHYLACTERY_ADDRESS=:42069 go run main.go
+    PHYLACTERY_LIBRARY=/path/to/library PHYLACTERY_ADDRESS=:42069 go run main.go
 
 ## Copying
 
diff --git a/main.go b/main.go
index c60be5b..4dbf016 100644
--- a/main.go
+++ b/main.go
@@ -137,10 +137,19 @@ func main() {
 				pages = append(pages, Page{i, f.Name})
 			}
 		}
+
+		prev := "";
+		if index > 0 {
+			prev = entries[index-1].Name()
+		}
+		next := "";
+		if index < len(entries) - 1 {
+			next = entries[index+1].Name()
+		}
 		t.ExecuteTemplate(w, "archive.html", Archive{
 			stat.Name(),
-			template.URL(entries[index-1].Name()),
-			template.URL(entries[index+1].Name()),
+			template.URL(prev),
+			template.URL(next),
 			pages,
 		})
 	})
diff --git a/templates/archive.html b/templates/archive.html
index c0cc144..3b20ae9 100644
--- a/templates/archive.html
+++ b/templates/archive.html
@@ -5,10 +5,12 @@
 <link rel=stylesheet href=/static/archive.css>
 <title>{{.Title}}</title>
 <body>
-  <nav>
-    <a id=prev href="{{.Prev}}">PREV</a>
-    <a id=up href=.>UP</a>
-    <a id=next href="{{.Next}}">NEXT</a>
+  <nav>{{if .Prev}}
+    <a id=prev href="{{.Prev}}">PREV</a>{{else}}
+    <a id=prev></a>{{end}}
+    <a id=up href=.>UP</a>{{if .Next}}
+    <a id=next href="{{.Next}}">NEXT</a>{{else}}
+    <a id=next></a>{{end}}
   </nav>
   <main>{{range .Entries}}
     <img src="?entry={{.Index}}" alt="{{.Name}}">{{end}}