diff options
author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2022-06-28 01:08:31 +0900 |
---|---|---|
committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2022-06-28 01:08:31 +0900 |
commit | b2195e98804c404e80a5cc4e649d4e59f0d40be7 (patch) | |
tree | aaedb7e0b7ef2ab5a9e35a17f543964a88b2c024 | |
parent | dd5e634482c2747d4514b784ec8dded9c7fa29cf (diff) | |
download | phylactery-b2195e98804c404e80a5cc4e649d4e59f0d40be7.tar.gz |
Fix adjacent links
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | main.go | 13 | ||||
-rw-r--r-- | 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 @@ <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}} |