From 0665d0c65974533fbd313f4e0b062b5103057aeb Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sat, 18 May 2024 18:29:19 +0200 Subject: Replace all URL rendering within templates by a URLConstructor --- src/gmi/tpl/posts/index.gmi | 11 +++++------ src/gmi/tpl/posts/post.gmi | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'src/gmi/tpl/posts') diff --git a/src/gmi/tpl/posts/index.gmi b/src/gmi/tpl/posts/index.gmi index 2ff296a..873222b 100644 --- a/src/gmi/tpl/posts/index.gmi +++ b/src/gmi/tpl/posts/index.gmi @@ -1,29 +1,28 @@ # 👻 mediocregopher's Posts {{ $page := .GetQueryIntValue "page" 0 -}} +{{ $getPostsRes := .GetPosts $page 20 -}} {{ if eq $page 0 -}} Here you'll find an archive of all published posts. The content varies almost as much as the quality! {{ end -}} -{{ $getPostsRes := .GetPosts $page 20 -}} - {{ if gt $page 0 -}} -=> {{ BlogURL "posts" }}/?page={{ .Add $page -1 }} Previous Page +=> {{ .RootURL.Posts.Page (.Add $page -1) }} Previous Page {{ end -}} {{ range $getPostsRes.Posts -}} -=> {{ PostURL .ID }} {{ .PublishedAt.Format "2006-01-02" }} - {{ .Title }} +=> {{ $.RootURL.Post .ID }} {{ .PublishedAt.Format "2006-01-02" }} - {{ .Title }} {{ end -}} {{ if $getPostsRes.HasMore -}} -=> {{ BlogURL "posts" }}/?page={{ .Add $page 1 }} Next page +=> {{ .RootURL.Posts.Page (.Add $page 1) }} Next page {{ end }} ======================================== -=> {{ BlogURL "feed.xml" }} RSS feed +=> {{ .RootURL.Path "feed.xml" }} RSS feed {{ template "footer.gmi" . }} diff --git a/src/gmi/tpl/posts/post.gmi b/src/gmi/tpl/posts/post.gmi index b568044..eafa76c 100644 --- a/src/gmi/tpl/posts/post.gmi +++ b/src/gmi/tpl/posts/post.gmi @@ -3,7 +3,7 @@ {{ if eq $post.Format "md" -}} This post has been translated from it's original markdown format, if it seems busted it might appear better over HTTP: -=> {{ PostHTTPURL $post.ID }} +=> {{ .RootURL.HTTP.Post $post.ID }} {{ end -}} @@ -26,18 +26,18 @@ Published {{ $post.PublishedAt.Format "2006-01-02" }} by mediocregopher This post is part of a series! {{ if $seriesNextPrev.Next -}} -=> {{ BlogURL "posts" }}/{{ $seriesNextPrev.Next.ID }}.gmi Next in the series: {{ $seriesNextPrev.Next.Title }} +=> {{ .RootURL.Post $seriesNextPrev.Next.ID }} Next in the series: {{ $seriesNextPrev.Next.Title }} {{ end -}} {{ if $seriesNextPrev.Previous -}} -=> {{ BlogURL "posts" }}/{{ $seriesNextPrev.Previous.ID }}.gmi Prevous in the series: {{ $seriesNextPrev.Previous.Title }} +=> {{ .RootURL.Post $seriesNextPrev.Previous.ID }} Prevous in the series: {{ $seriesNextPrev.Previous.Title }} {{ end -}} {{ end -}} {{ else }}{{/* newline */}} {{ end }} -=> {{ BlogURL "posts/" }} Browse all posts +=> {{ .RootURL.Posts }} Browse all posts -=> {{ BlogURL "feed.xml" }} RSS feed +=> {{ .RootURL.Path "feed.xml" }} RSS feed {{ template "footer.gmi" . }} -- cgit v1.2.3