repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

commit
3f2624b
parent
70400f7
author
Eric Bower
date
2025-05-11 22:06:45 -0400 EDT
feat(prose): display post's last updated timestamp on page
2 files changed,  +13, -3
M pkg/apps/prose/api.go
+6, -0
 1@@ -87,6 +87,8 @@ type PostPageData struct {
 2 	Favicon      template.URL
 3 	Unlisted     bool
 4 	Diff         template.HTML
 5+	UpdatedAtISO string
 6+	UpdatedAt    string
 7 }
 8 
 9 type HeaderTxt struct {
10@@ -426,6 +428,8 @@ func postHandler(w http.ResponseWriter, r *http.Request) {
11 			Slug:         post.Slug,
12 			PublishAt:    post.PublishAt.Format(time.DateOnly),
13 			PublishAtISO: post.PublishAt.Format(time.RFC3339),
14+			UpdatedAt:    post.UpdatedAt.Format(time.DateOnly),
15+			UpdatedAtISO: post.UpdatedAt.Format(time.RFC3339),
16 			Username:     username,
17 			BlogName:     blogName,
18 			Contents:     template.HTML(parsedText.Html),
19@@ -471,6 +475,8 @@ func postHandler(w http.ResponseWriter, r *http.Request) {
20 			Title:        title,
21 			PublishAt:    time.Now().Format(time.DateOnly),
22 			PublishAtISO: time.Now().Format(time.RFC3339),
23+			UpdatedAt:    post.UpdatedAt.Format(time.DateOnly),
24+			UpdatedAtISO: post.UpdatedAt.Format(time.RFC3339),
25 			Username:     username,
26 			BlogName:     blogName,
27 			HasCSS:       hasCSS,
M pkg/apps/prose/html/post.page.tmpl
+7, -3
 1@@ -66,9 +66,13 @@
 2         {{.Contents}}
 3 
 4         <div class="tags">
 5-        {{range .Tags}}
 6-            <code class="pill tag"><a href="{{$.BlogURL}}?tag={{.}}">#{{.}}</a></code>
 7-        {{end}}
 8+          {{range .Tags}}
 9+              <code class="pill tag"><a href="{{$.BlogURL}}?tag={{.}}">#{{.}}</a></code>
10+          {{end}}
11+        </div>
12+
13+        <div id="last-updated" class="text-sm">
14+          last updated: <time datetime="{{.UpdatedAtISO}}">{{.UpdatedAt}}</time>
15         </div>
16 
17         <div id="post-footer">{{.Footer}}</div>