Add about me section

This commit is contained in:
2025-09-01 13:14:29 +02:00
parent f4ef9fcbea
commit 0e6ddfede4
8 changed files with 124 additions and 6 deletions

27
main.go
View File

@ -38,6 +38,9 @@ type PageData struct {
ErrorMessage string
SuccessMessage string
FormData ContactForm
AboutName string
AgeYears int
SonAgeYears int
}
// ContactForm holds form data
@ -311,6 +314,29 @@ func (s *Server) healthHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`{"status":"healthy","service":"linuxservice"}`))
}
// aboutHandler handles the About Me page
func (s *Server) aboutHandler(w http.ResponseWriter, r *http.Request) {
data := s.createPageData("Over mij - "+s.config.CompanyName, "about")
// Populate dynamic About fields
data.AboutName = "Brendon Bosman"
now := time.Now()
birthYear, birthMonth, birthDay := 1990, time.October, 17
age := now.Year() - birthYear
if now.Month() < birthMonth || (now.Month() == birthMonth && now.Day() < birthDay) {
age--
}
data.AgeYears = age
sonYear, sonMonth, sonDay := 2022, time.March, 11
sonAge := now.Year() - sonYear
if now.Month() < sonMonth || (now.Month() == sonMonth && now.Day() < sonDay) {
sonAge--
}
data.SonAgeYears = sonAge
s.renderTemplate(w, "over-mij.html", data)
}
// setupRoutes configures all HTTP routes
func (s *Server) setupRoutes() {
// Static files
@ -320,6 +346,7 @@ func (s *Server) setupRoutes() {
// Page routes
http.HandleFunc("/", s.homeHandler)
http.HandleFunc("/contact", s.contactHandler)
http.HandleFunc("/over-mij", s.aboutHandler)
http.HandleFunc("/health", s.healthHandler)
}