templates/page.templ (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | package templates
import (
"go.alanpearce.eu/homestead/internal/config"
"go.alanpearce.eu/homestead/internal/content"
)
templ Page(config *config.Config, page *content.Post) {
@Layout(config, PageSettings{
Title: page.Title,
TitleAttrs: templ.Attributes{
"class": "h-card",
"rel": "author",
},
Path: page.URL,
}) {
<article>
<header>
<h1 class="p-name">{ page.Title }</h1>
<p class="meta">
if !page.Date.IsZero() {
<span class="date">
Published:
<a class="u-url" href={ templ.SafeURL(page.URL) }>
@postDate(page.Date, "dt-published")
</a>
</span>
}
// one commit: not updated
if (page.Date.IsZero() && len(page.Commits) > 0) || len(page.Commits) > 1 {
<span class="date last-updated">
Last updated:
<a href={ templ.URL(page.Commits[0].Link.String()) }>
@postDate(page.Commits[0].Date, "dt-updated")
</a>
</span>
}
</p>
</header>
</article>
<div class="content">
@page
</div>
}
}
|