diff options
| author | Mikkel Thestrup <mikkel_thestrup@mithe.dk> | 2025-12-06 23:17:58 +0100 |
|---|---|---|
| committer | Mikkel Thestrup <mikkel_thestrup@mithe.dk> | 2025-12-06 23:17:58 +0100 |
| commit | 94646c018dfc87a7f1f9e11dc3e85d1af57899f0 (patch) | |
| tree | f27ed95c79e00d7a3f65f0e24c8f3a0ba70bbd06 | |
| parent | 0015442a40e6fb9c21eff0d0df29d5cd7cf856bc (diff) | |
| download | web-portfolio-94646c018dfc87a7f1f9e11dc3e85d1af57899f0.tar.gz web-portfolio-94646c018dfc87a7f1f9e11dc3e85d1af57899f0.zip | |
bug fix
| -rw-r--r-- | internal/handlers.go | 16 | ||||
| -rw-r--r-- | internal/models.go | 6 |
2 files changed, 15 insertions, 7 deletions
diff --git a/internal/handlers.go b/internal/handlers.go index 5d66be8..09fcaec 100644 --- a/internal/handlers.go +++ b/internal/handlers.go @@ -40,7 +40,21 @@ func (s *Server) handleHTMXPage(c echo.Context) error { if !validPage(page) { return c.String(http.StatusNotFound, "Page not found") } - return s.renderContent(c, page, PageSections[page][0]) + + content, err := s.tmpl.GetContent(page, PageSections[page][0]) + if err != nil { + log.Printf("Error rendering content for %s: %v", page, err) + return c.String(http.StatusInternalServerError, "Error loading content") + } + + data := PageData{ + Page: page, + Pages: ValidPages, + Sections: PageSections[page], + Content: content, + } + + return c.Render(http.StatusOK, "page.html", data) } func (s *Server) handleHTMXSection(c echo.Context) error { diff --git a/internal/models.go b/internal/models.go index 1fb0774..0ad4cfc 100644 --- a/internal/models.go +++ b/internal/models.go @@ -24,9 +24,3 @@ type PageData struct { Sections []string Content template.HTML } - -type SectionData struct { - Page string - Sections []string - Content template.HTML -} |