From 8d7e708d98a3a46ba3ba08f9c8deeb4838bb8ca5 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Fri, 17 May 2024 23:37:43 +0200 Subject: Render posts completely using common rendering methods The aim is to reduce reliance on custom logic in the handlers for every protocol, eventually outsourcing all of it into `render.Methods`, leaving each protocol to simply direct calls to the correct template. --- src/http/tpl/post.html | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/http/tpl/post.html') diff --git a/src/http/tpl/post.html b/src/http/tpl/post.html index db69302..0cf3622 100644 --- a/src/http/tpl/post.html +++ b/src/http/tpl/post.html @@ -1,45 +1,51 @@ {{ define "body" }} +{{ $post := .GetThisPost -}}

- {{ .Payload.Title }} + {{ $post.Title }}

-{{ if ne .Payload.Description "" }} +{{ if ne $post.Description "" }}

- - {{ .Payload.Description }} + - {{ $post.Description }}

{{ end }}
-{{ .Payload.Body }} +{{ .PostHTMLBody $post }}

- Published {{ DateTimeFormat .Payload.PublishedAt }} + Published {{ DateTimeFormat $post.PublishedAt }}

-{{ if (or .Payload.SeriesPrevious .Payload.SeriesNext) }} +{{- if $post.Series }} +{{ $seriesNextPrev := .GetPostSeriesNextPrevious $post -}} +{{ if or $seriesNextPrev.Next $seriesNextPrev.Previous }}

This post is part of a series.
- {{ if .Payload.SeriesPrevious }} - Previously: {{ .Payload.SeriesPrevious.Title }} + {{ if $seriesNextPrev.Next }} + Next: {{ $seriesNextPrev.Next.Title }} {{ end }} - {{ if (and .Payload.SeriesNext .Payload.SeriesPrevious) }} + {{ if and $seriesNextPrev.Next $seriesNextPrev.Previous }}
{{ end }} - {{ if .Payload.SeriesNext }} - Next: {{ .Payload.SeriesNext.Title }}
+ {{ if $seriesNextPrev.Previous }} + Previously: {{ $seriesNextPrev.Previous.Title }} +
{{ end }}

{{ end }} +{{ end }} {{ template "gemini-cta.html" . }} {{ end }} -{{ template "base.html" . }} +{{ $post := .GetThisPost -}} +{{ template "base.html" (.WithTitlePrefix $post.Title) }} -- cgit v1.2.3