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/post.templ | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 internal/builder/post.templ (limited to 'internal/builder/post.templ') diff --git a/internal/builder/post.templ b/internal/builder/post.templ new file mode 100644 index 0000000..740c5aa --- /dev/null +++ b/internal/builder/post.templ @@ -0,0 +1,50 @@ +package builder + +import ( + "time" + "website/internal/config" +) + +func Unsafe(html string) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) { + _, err = io.WriteString(w, html) + return + }) +} + +templ postDate(d time.Time) { + +} + +templ postPage(config config.Config, post Post) { + @page(config, PageSettings{ + Title: post.Title, + TitleAttrs: templ.Attributes{ + "class": "p-author h-card", + "rel": "author", + }, + Path: post.URL, + }) { +
+

{ post.Title }

+

+ @postDate(post.Date) +

+
+ @Unsafe(post.Content) +
+
+ Tags: + +
+
+ } +} -- cgit 1.4.1