fix: resolve translated post slugs (D-58)

GET /_journal/api/v1/posts/{slug} now looks the slug up in translate's
slug index for the request locale after the default-locale slug and
before the numeric id. TestTranslatedSlug covers the translated slug,
the default slug, the id and an unknown slug.
This commit is contained in:
2026-10-26 22:46:49 +01:00
parent e17cebd761
commit a598a7c5e7
4 changed files with 105 additions and 3 deletions

View File

@@ -128,7 +128,7 @@ func Show(app *backpack.App) http.HandlerFunc {
}
db = db.WithContext(r.Context())
slug := strings.TrimSpace(r.PathValue("slug"))
post, err := findPostBySlugOrID(db, slug)
post, err := findPostBySlugOrID(db, slug, requestLocale(r))
if err != nil || post == nil {
writeAPIError(w, http.StatusNotFound, errPostNotFound)
return