From a2feb8c63c80a1f52830f562af2deb2c6065eaae Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 24 Jun 2024 21:48:36 +0200 Subject: move templ templates into separate package --- templates/post.templ | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 templates/post.templ (limited to 'templates/post.templ') diff --git a/templates/post.templ b/templates/post.templ new file mode 100644 index 0000000..5b09d4b --- /dev/null +++ b/templates/post.templ @@ -0,0 +1,51 @@ +package templates + +import ( + "time" + "website/internal/config" + "website/internal/content" +) + +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 content.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