diff --git a/controllers/static.go b/controllers/static.go index ed0e68b..8d6f009 100644 --- a/controllers/static.go +++ b/controllers/static.go @@ -7,8 +7,8 @@ import ( "strings" ) -func StaticTemplate(templatePath string) http.HandlerFunc { - tpl := views.Must(views.FromFS(templates.FS, templatePath)) +func StaticTemplate(templatePath ...string) http.HandlerFunc { + tpl := views.Must(views.FromFS(templates.FS, templatePath...)) var testWriter strings.Builder err := tpl.ExecuteWriter(&testWriter, nil) @@ -19,7 +19,7 @@ func StaticTemplate(templatePath string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { tpl.Execute(w, nil) } } -func FAQ(templatePath string) http.HandlerFunc { +func FAQ(templatePath ...string) http.HandlerFunc { questions := []struct { Question string Answer string @@ -34,7 +34,7 @@ func FAQ(templatePath string) http.HandlerFunc { }, } - tpl := views.Must(views.FromFS(templates.FS, templatePath)) + tpl := views.Must(views.FromFS(templates.FS, templatePath...)) var testWriter strings.Builder err := tpl.ExecuteWriter(&testWriter, nil) diff --git a/main.go b/main.go index 2fb796d..bc32995 100644 --- a/main.go +++ b/main.go @@ -18,9 +18,9 @@ func notFoundHandler(w http.ResponseWriter, r *http.Request) { func main() { r := chi.NewRouter() r.Use(middleware.Logger) - r.Get("/", ctrlrs.StaticTemplate("home.gohtml")) - r.Get("/contact", ctrlrs.StaticTemplate("contact.gohtml")) - r.Get("/faq", ctrlrs.FAQ("faq.gohtml")) + r.Get("/", ctrlrs.StaticTemplate("home.gohtml", "tailwind.gohtml")) + r.Get("/contact", ctrlrs.StaticTemplate("contact.gohtml", "tailwind.gohtml")) + r.Get("/faq", ctrlrs.FAQ("faq.gohtml", "tailwind.gohtml")) r.NotFound(notFoundHandler) fmt.Println("Starting the server on :3000...") http.ListenAndServe(":3000", r) diff --git a/templates/contact.gohtml b/templates/contact.gohtml index 5b55289..b1a4ba5 100644 --- a/templates/contact.gohtml +++ b/templates/contact.gohtml @@ -1,2 +1,9 @@ -
To get in touch, email me at example@example.com
+ + + {{template "head" .}} + +To get in touch, email me at example@example.com
+ {{template "footer" .}} + + diff --git a/templates/faq.gohtml b/templates/faq.gohtml index d103002..4492c8c 100644 --- a/templates/faq.gohtml +++ b/templates/faq.gohtml @@ -1,10 +1,24 @@ -{{.Answer}}
+{{.Answer}}
+- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor - incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis - nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore - eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt - in culpa qui officia deserunt mollit anim id est laborum. -
++ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor + incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis + nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. + Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore + eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt + in culpa qui officia deserunt mollit anim id est laborum. +
{{end}}