From 1d247493e05cdc659e46cd3d8a01d5da1e893867 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Tue, 18 Jun 2024 16:46:22 +0200 Subject: switch to templ for rendering HTML templates --- internal/builder/page.templ | 84 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 internal/builder/page.templ (limited to 'internal/builder/page.templ') diff --git a/internal/builder/page.templ b/internal/builder/page.templ new file mode 100644 index 0000000..c99e315 --- /dev/null +++ b/internal/builder/page.templ @@ -0,0 +1,84 @@ +package builder + +import ( + "net/url" + "website/internal/config" +) + +type PageSettings struct { + Title string + Path string + TitleAttrs templ.Attributes + BodyAttrs templ.Attributes +} + +func extendClasses(cs string, attrs templ.Attributes) string { + if extras, exists := attrs["class"]; exists { + return templ.Classes(cs, extras).String() + } else { + return cs + } +} + +templ page(site config.Config, page PageSettings) { + + +
+ + +