Browse Source

Put the previous post on the left and the next on the right

The post page links now read in time order: older (previous) on the
left, newer (next) on the right. Test the order. Version 0.5.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude 1 day ago
parent
commit
d163b8d2a7

+ 6 - 2
main_test.go

@@ -98,13 +98,17 @@ func TestPostPage(t *testing.T) {
 	for _, want := range []string{
 		"<title>Middle · posts.example.com</title>",
 		"<p>Middle body</p>",
-		`<a class="newer" href="/posts/newest">`,
-		`<a class="older" href="/posts/oldest">`,
+		`<a class="older" href="/posts/oldest">← Oldest</a>`,
+		`<a class="newer" href="/posts/newest">Newest →</a>`,
 	} {
 		if !strings.Contains(body, want) {
 			t.Errorf("missing %q in:\n%s", want, body)
 		}
 	}
+	// Previous (older) on the left, next (newer) on the right.
+	if strings.Index(body, `class="older"`) > strings.Index(body, `class="newer"`) {
+		t.Error("older link should come before the newer link")
+	}
 
 	_, _, newest := get(t, srv, "/posts/newest")
 	if strings.Contains(newest, `class="newer"`) {

+ 36 - 0
pull-releases/009-pager-order/README.md

@@ -0,0 +1,36 @@
+# Put the previous post on the left and the next on the right
+
+Branch `feature/pager-order` · version 0.5.2
+
+## What changed
+
+- **Post page links swapped.** The links at the bottom of a post now read in time order: the **previous (older)** post on the left with ←, the **next (newer)** post on the right with →. Before, the newer post was on the left.
+- **A post with only one neighbour** keeps that link on its own side: the oldest post shows only "next" on the right, and the newest shows only "previous" on the left.
+- **Test:** the post page test checks both link texts and that the older link comes first.
+- **Version:** 0.5.2.
+
+## Notes
+
+- Which posts the links point to hasn't changed: they still follow date order, ignoring pins (v0.5.0). Only their placement swapped.
+- The release notes page's "← All release notes" link is unaffected.
+- The stylesheet changes, so its content hash does too, and browsers fetch it on their next visit.
+
+## Testing
+
+- All tests pass with the race detector (`go test -race ./...`).
+- Checked a first, middle and last post: the middle post shows "← The first post" on the left and "The third post →" on the right; the first and last show one link each on the correct side. Desktop and mobile both checked.
+- With the real posts, the Go 1.27 post shows "← VPS part 5" on the left and "Why This Project Exists →" on the right.
+
+| Before | After |
+|---|---|
+| [![Before](pager-before.png)](pager-before.png) | [![After](pager-after.png)](pager-after.png) |
+
+## Screenshots
+
+From the branch's build running locally. The home page doesn't change.
+
+| Desktop | Mobile |
+|---|---|
+| [![Desktop](desktop.png)](desktop.png) | [![Mobile](mobile.png)](mobile.png) |
+
+🤖 Generated with [Claude Code](https://claude.com/claude-code)

BIN
pull-releases/009-pager-order/desktop.png


BIN
pull-releases/009-pager-order/mobile.png


BIN
pull-releases/009-pager-order/pager-after.png


BIN
pull-releases/009-pager-order/pager-before.png


+ 1 - 0
pull-releases/README.md

@@ -35,3 +35,4 @@ screenshot, or its `README.md` doesn't load.
 | [006](006-go-1-27/) | Require Go 1.27.3 (security fixes) |
 | [007](007-pinned-posts/) | Pinned posts |
 | [008](008-tab-size/) | Tabs in code blocks 4 columns wide |
+| [009](009-pager-order/) | Previous post on the left, next on the right |

+ 1 - 1
static/style.css

@@ -110,4 +110,4 @@ hr { border: 0; border-top: 1px solid var(--rule); }
   padding-top: 1rem;
   border-top: 1px solid var(--rule);
 }
-.pager .older { margin-left: auto; text-align: right; }
+.pager .newer { margin-left: auto; text-align: right; }

+ 2 - 2
templates/post.html

@@ -8,7 +8,7 @@
   </div>
 </article>
 <nav class="pager">
-  {{with .Newer}}<a class="newer" href="/posts/{{.Slug}}">← {{.Title}}</a>{{end}}
-  {{with .Older}}<a class="older" href="/posts/{{.Slug}}">{{.Title}} →</a>{{end}}
+  {{with .Older}}<a class="older" href="/posts/{{.Slug}}">← {{.Title}}</a>{{end}}
+  {{with .Newer}}<a class="newer" href="/posts/{{.Slug}}">{{.Title}} →</a>{{end}}
 </nav>
 {{end}}

+ 1 - 1
version.go

@@ -4,7 +4,7 @@ import "runtime/debug"
 
 // version is the release number shown on the About page. Bump it in the PR
 // that makes a user-visible change.
-const version = "0.5.1"
+const version = "0.5.2"
 
 // buildCommit returns the short git revision that `go build` stamped into the
 // binary, with "-dirty" if the tree had uncommitted changes, or "" if the