feat: slug on the post author object, for author links that do not expose the login

This commit is contained in:
Jakub Zych
2026-10-31 13:11:44 +01:00
parent 08e3d82ecd
commit f7bfb3313b
3 changed files with 26 additions and 6 deletions

View File

@@ -293,8 +293,16 @@ func TestJournalAuthorPosts(t *testing.T) {
t.Fatalf("author row keys = %v, want /posts row keys %v", got, want)
}
author, _ := page.Data[0]["author"].(map[string]any)
if author == nil || author["login"] != "jdoe" {
t.Fatalf("row author = %v, want login jdoe", page.Data[0]["author"])
if author == nil || author["login"] != "jdoe" || author["slug"] != "jane-doe" {
t.Fatalf("row author = %v, want login jdoe and slug jane-doe", page.Data[0]["author"])
}
// Without an author slug, the row's slug is the login.
for _, row := range all.Data {
if row["slug"] == "b1" {
if a, _ := row["author"].(map[string]any); a == nil || a["slug"] != "bob" {
t.Fatalf("b1 author = %v, want slug bob", row["author"])
}
}
}
page = getAuthorPosts(t, env, base+"?per_page=2&page=2", "")