From 2929b4279c7a8128bd305290cc4187b6afb11cde Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Fri, 13 May 2022 11:47:29 -0600 Subject: Implement rendering Posts to html --- srv/src/tpl/html/base.html | 65 ++++++++++++++++++++++++++++++++++++++++++++++ srv/src/tpl/html/post.html | 48 ++++++++++++++++++++++++++++++++++ srv/src/tpl/tpl.go | 12 +++++++++ 3 files changed, 125 insertions(+) create mode 100644 srv/src/tpl/html/base.html create mode 100644 srv/src/tpl/html/post.html create mode 100644 srv/src/tpl/tpl.go (limited to 'srv/src/tpl') diff --git a/srv/src/tpl/html/base.html b/srv/src/tpl/html/base.html new file mode 100644 index 0000000..bf81032 --- /dev/null +++ b/srv/src/tpl/html/base.html @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + +
+ + + + {{ template "body" . }} + +
+

+ Unless otherwised specified, all works are licensed under the + WTFPL. +

+
+ +
+ + + + + diff --git a/srv/src/tpl/html/post.html b/srv/src/tpl/html/post.html new file mode 100644 index 0000000..22a5b97 --- /dev/null +++ b/srv/src/tpl/html/post.html @@ -0,0 +1,48 @@ +{{ define "body" }} + +
+

+ {{ .Title }} +

+
+ {{ .PublishedAt.Format "2006-01-02" }} +  •  + {{ if not .LastUpdatedAt.IsZero }} + (Updated {{ .LastUpdatedAt.Format "2006-01-02" }}) +  •  + {{ end }} + {{ .Description }} +
+
+ +{{ if (or .SeriesPrevious .SeriesNext) }} +

+ This post is part of a series:
+ {{ if .SeriesPrevious }} + Previously: {{ .SeriesPrevious.Title }}
+ {{ end }} + {{ if .SeriesNext }} + Next: {{ .SeriesNext.Title }}
+ {{ end }} +

+{{ end }} + +
+ {{ .Body }} +
+ +{{ if (or .SeriesPrevious .SeriesNext) }} +

+ If you liked this post, consider checking out other posts in the series:
+ {{ if .SeriesPrevious }} + Previously: {{ .SeriesPrevious.Title }}
+ {{ end }} + {{ if .SeriesNext }} + Next: {{ .SeriesNext.Title }}
+ {{ end }} +

+{{ end }} + +{{ end }} + +{{ template "base.html" . }} diff --git a/srv/src/tpl/tpl.go b/srv/src/tpl/tpl.go new file mode 100644 index 0000000..1dd98ba --- /dev/null +++ b/srv/src/tpl/tpl.go @@ -0,0 +1,12 @@ +// Package tpl contains template files which are used to render the blog. +package tpl + +import ( + "embed" + html_tpl "html/template" +) + +//go:embed * +var fs embed.FS + +var HTML = html_tpl.Must(html_tpl.ParseFS(fs, "html/*")) -- cgit v1.2.3