hugo-theme-bootstrap5-blog/layouts/_default/home.html
Alan Orth f28cf4615c
layouts: Make featured posts configurable
For now it gets the first three posts with "featured: true" in their
frontmatter and displays them in a random order (so no control over
the placement of large feature or two smaller features).

TODO: gracefully handle the case where there are no pages with the
"featured: true" frontmatter so new users don't see a super weird
and broken front page.
2020-12-28 10:03:41 +02:00

60 lines
1.6 KiB
HTML

{{ define "title" }}{{ .Site.Title }}{{ end }}
{{ define "schema-dot-org" }}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Blog",
{{- /* Google recommends the headline be no more than 110 characters */}}
"headline": {{ substr .Site.Title 0 110 }},
"url" : {{ printf "%s" .Permalink }},
"author": {
"@type": "Person",
"name": {{ .Site.Params.author }}
},
{{- $ISO8601 := "2006-01-02T15:04:05-07:00" }}
{{- if not .Date.IsZero }}
"dateModified": {{ .Date.Format $ISO8601 }},
{{- end }}
{{- /* all of the site's categories/tags, from Hugo's tpl/template_embedded.go */}}
{{- $keywords := slice }}{{ range $plural, $terms := .Site.Taxonomies }}{{ range $term, $val := $terms }}{{ $keywords = $keywords | append $term }}{{ end }}{{ end }}
"keywords": {{ delimit $keywords ", " }}
{{- with .Site.Params.description -}}
,
"description": {{- . -}}
{{- end }}
}
</script>
{{ end }}
{{ define "main" }}
{{ $dateFormat := default "Mon Jan 2, 2006" (index .Site.Params "date_format") }}
{{ partial "featured.html" . }}
<div class="row">
<div class="col-md-8">
<h3 class="pb-4 mb-4 fst-italic border-bottom">
From the Firehose
</h3>
{{ $truncate := default true .Site.Params.truncate }}
{{ $paginator := .Paginate (where .Site.RegularPages "Params.featured" "ne" true) }}
{{ range $paginator.Pages }}
{{ if $truncate }}
{{ .Render "summary" }}
{{ else }}
{{ .Render "content" }}
{{ end }}
{{ end }}
{{ if or (.Paginator.HasPrev) (.Paginator.HasNext) }}
{{ partial "pagination.html" . }}
{{ end }}
</div>
{{ end }}
{{- /* vim: set ts=2 sw=2 et: */}}