incorporate related posts to site

This commit is contained in:
Peter 2025-03-17 20:26:21 -04:00
parent a586833f65
commit c7102e0628
3 changed files with 73 additions and 0 deletions

View file

@ -59,6 +59,7 @@ defaultContentLanguage = 'es'
name = "código-fuente"
weight = 3
url = "https://gitlab.com/putridpete/hugo-website"
icon = "fa-brands fa-gitlab"
[[menu.header]]
name = "rss"
weight = 4

View file

@ -0,0 +1,64 @@
{{ define "title"}}
{{ .Title }} | {{ .Site.Params.author.name }}
{{ end }}
{{ define "main" }}
<div class="postWrapper">
<h1>{{ .Title }}</h1>
{{ if .Description}}
<p>{{.Description}}</p>
{{ end }}
{{ if .Params.showMetadata | default true }}
<section class="postMetadata">
<dl>
{{ with .GetTerms "tags" }}
{{ partial "taxonomy/tags.html" . }}
{{ end }}
{{ with .GetTerms "authors" }}
{{ partial "taxonomy/authors.html" . }}
{{ end }}
{{ with .GetTerms "categories" }}
{{ partial "taxonomy/categories.html" . }}
{{ end }}
{{ if .Site.Params.published | default true }}
<dt>{{ i18n "published" }}</dt>
{{ $formattedDate := .Date.Format "2006-01-02" }}
<dd><time datetime="{{ $formattedDate }}">{{ .Date | time.Format ":date_long" }}</time></dd>
{{ end }}
{{ if .Site.Params.readingTime | default true }}
<dt>{{ i18n "reading_time" }}</dt>
<dd>{{ i18n "reading_time_desc" .ReadingTime }}</dd>
{{ end }}
</dl>
</section>
{{ end }}
<div>
{{ .Content }}
</br>
{{ $related := .Site.RegularPages.Related . | first 5 }}
{{ with $related }}
<h2>Leer también:</h2>
<section class="postMetadata">
<ul>
{{ range $i, $p := . }}
<li>
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></font>
{{ with .HeadingsFiltered }}
<ul>
{{ range . }}
{{ $link := printf "%s#%s" $p.RelPermalink .ID | safeURL }}
<li>
<a href="{{ $link }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ end }}
</li>
{{ end }}
</ul>
{{ end }}
</div>
</div>
</br>
</div>
{{ end }}

View file

@ -0,0 +1,8 @@
{{ with site.RegularPages.Related . | first 5 }}
<p>Related content:</p>
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}