summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/handlers.go17
-rw-r--r--internal/models.go9
-rw-r--r--internal/template.go12
3 files changed, 29 insertions, 9 deletions
diff --git a/internal/handlers.go b/internal/handlers.go
index 09fcaec..c151904 100644
--- a/internal/handlers.go
+++ b/internal/handlers.go
@@ -44,10 +44,12 @@ func (s *Server) handleHTMXPage(c echo.Context) error {
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")
+ return c.String(
+ http.StatusInternalServerError,
+ "Error loading content")
}
- data := PageData{
+ data := PageData {
Page: page,
Pages: ValidPages,
Sections: PageSections[page],
@@ -75,8 +77,12 @@ func (s *Server) handleHTMXSection(c echo.Context) error {
func (s *Server) renderFullPage(c echo.Context, page, section string) error {
content, err := s.tmpl.GetContent(page, section)
if err != nil {
- log.Printf("Error rendering content for %s/%s: %v", page, section, err)
- return c.String(http.StatusInternalServerError, "Error loading content")
+ log.Printf(
+ "Error rendering content for %s/%s: %v",
+ page, section, err)
+ return c.String(
+ http.StatusInternalServerError,
+ "Error loading content")
}
data := PageData{
@@ -93,7 +99,8 @@ func (s *Server) renderContent(c echo.Context, page, section string) error {
content, err := s.tmpl.GetContent(page, section)
if err != nil {
log.Printf("Error rendering content for %s/%s: %v", page, section, err)
- return c.String(http.StatusInternalServerError, "Error loading content")
+ return c.String(
+ http.StatusInternalServerError, "Error loading content")
}
return c.HTML(http.StatusOK, string(content))
diff --git a/internal/models.go b/internal/models.go
index 0ad4cfc..4c8b4e0 100644
--- a/internal/models.go
+++ b/internal/models.go
@@ -9,12 +9,17 @@ const (
PageContact = "contact"
)
-var ValidPages = []string{PageHome, PageProjects, PageResume, PageContact}
+var ValidPages = []string{
+ PageHome,
+ PageProjects,
+ PageResume,
+ PageContact,
+}
var PageSections = map[string][]string{
PageHome: {"intro", "about"},
PageProjects: {"intro", "kal"},
- PageResume: {"intro", "BSc in Computer Science"},
+ PageResume: {"intro", "BSc Comp. Sci."},
PageContact: {"contact"},
}
diff --git a/internal/template.go b/internal/template.go
index 118f7a2..3800aef 100644
--- a/internal/template.go
+++ b/internal/template.go
@@ -29,11 +29,19 @@ func NewTemplateEngine() (*TemplateEngine, error) {
return &TemplateEngine{tmpl: tmpl}, nil
}
-func (te *TemplateEngine) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
+func (te *TemplateEngine) Render(
+ w io.Writer,
+ name string,
+ data interface{},
+ c echo.Context,
+) error {
return te.tmpl.ExecuteTemplate(w, name, data)
}
-func (te *TemplateEngine) GetContent(page, section string) (template.HTML, error) {
+func (te *TemplateEngine) GetContent(
+ page,
+ section string,
+) (template.HTML, error) {
templateName := fmt.Sprintf("%s_%s", page, section)
var buf bytes.Buffer