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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user