From b2195e98804c404e80a5cc4e649d4e59f0d40be7 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Tue, 28 Jun 2022 01:08:31 +0900 Subject: Fix adjacent links --- README.md | 2 +- main.go | 13 +++++++++++-- templates/archive.html | 10 ++++++---- 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 @@ {{.Title}} -