mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 19:53:21 +02:00
feat: post list and edition redirect
This commit is contained in:
+11
-1
@@ -1,15 +1,25 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
"html/template"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetPostEditPage(w http.ResponseWriter, _ *http.Request) {
|
||||
func GetPostEditPage(w http.ResponseWriter, r *http.Request) {
|
||||
postName := chi.URLParam(r, "name")
|
||||
if len(postName) == 0 {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
post, _ := Container.GetPostUseCase.GetPostByName(postName)
|
||||
|
||||
navbarTmpl, _ := Container.GetPageUseCase.GetPage("componentNavbar", nil)
|
||||
postsTmpl, _ := Container.GetPageUseCase.GetPage("postEdit", map[string]interface{}{
|
||||
"Navbar": template.HTML(navbarTmpl),
|
||||
"Head": headTmpl,
|
||||
"Body": post.Body,
|
||||
})
|
||||
_, _ = w.Write(postsTmpl)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user