From 83253f03c4411f093156bc61bcda8afdac56786f Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Mon, 12 Oct 2020 19:26:32 +0200 Subject: [PATCH] Fix blog-relative links --- render.go | 6 ++++++ templates/header.gohtml | 2 +- templates/post.gohtml | 5 +++-- templates/taxonomy.gohtml | 3 ++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/render.go b/render.go index 7c27b3b..417450a 100644 --- a/render.go +++ b/render.go @@ -77,6 +77,12 @@ func initRendering() error { }, "urlize": urlize, "sort": sortedStrings, + "blogRelative": func(blog *configBlog, path string) string { + if blog.Path != "/" { + return blog.Path + path + } + return path + }, } templates = make(map[string]*template.Template) diff --git a/templates/header.gohtml b/templates/header.gohtml index ba9d9a5..c100edb 100644 --- a/templates/header.gohtml +++ b/templates/header.gohtml @@ -1,6 +1,6 @@ {{ define "header" }}
-

{{ .Blog.Title }}

+

{{ .Blog.Title }}

{{ with .Blog.Description }}

{{ . }}

{{ end }} {{ include "menu" .Blog .Data }}
diff --git a/templates/post.gohtml b/templates/post.gohtml index a929dfc..637dd6b 100644 --- a/templates/post.gohtml +++ b/templates/post.gohtml @@ -15,12 +15,13 @@ {{ end }} {{ $post := .Data }} - {{ range $i, $tax := .Blog.Taxonomies }} + {{ $blog := .Blog }} + {{ range $i, $tax := $blog.Taxonomies }} {{ $tvs := ps $post $tax.Name }} {{ if gt (len $tvs) 0 }}

In {{ $tax.Title }}: {{ range $j, $tv := $tvs }} - {{ $tv }} + {{ $tv }} {{ end }}

{{ end }} diff --git a/templates/taxonomy.gohtml b/templates/taxonomy.gohtml index db2aebf..b08e5e8 100644 --- a/templates/taxonomy.gohtml +++ b/templates/taxonomy.gohtml @@ -7,9 +7,10 @@ {{ with .Data.Taxonomy.Title }}

{{ . }}

{{ end }} {{ with .Data.Taxonomy.Description }}{{ md . }}{{ end }}