Index template: Link to feeds in head

This commit is contained in:
Jan-Lukas Else 2020-09-02 17:56:18 +02:00
parent 341d9ab3f5
commit e1a77bf48a
2 changed files with 17 additions and 1 deletions

View File

@ -53,6 +53,7 @@ type indexTemplateData struct {
Posts []*Post
HasPrev bool
HasNext bool
First string
Prev string
Next string
}
@ -162,6 +163,7 @@ func serveIndex(path string, sec *section, tax *taxonomy, taxonomyValue string)
Posts: posts,
HasPrev: p.HasPrev(),
HasNext: p.HasNext(),
First: path,
Prev: fmt.Sprintf("%s/page/%d", path, prevPage),
Next: fmt.Sprintf("%s/page/%d", path, nextPage),
})

View File

@ -1,12 +1,26 @@
{{ define "title" }}
<title>{{ blog.Title }}</title>
<link rel="alternate"
type="application/rss+xml"
title="RSS"
href="{{ .First }}?feed=rss"/>
<link rel="alternate"
type="application/atom+xml"
title="Atom"
href="{{ .First }}?feed=atom"/>
<link rel="alternate"
type="application/feed+json"
title="JSON Feed"
href="{{ .First }}?feed=json"/>
{{ end }}
{{ define "main" }}
<main>
{{ with .Title }}<h1>{{ . }}</h1>{{ end }}
{{ with .Description }}{{ md . }}{{ end }}
{{ if (or .Title .Description) }}<hr>{{ end }}
{{ if (or .Title .Description) }}
<hr>
{{ end }}
{{ range $i, $post := .Posts }}
{{ include "summary" . }}
{{ end }}