Hi. How to get a list of last updated articles from a section like this one:
https://gohugoio.netlify.app/maintenance/
I would like to build a shortcode for this.
Hi. How to get a list of last updated articles from a section like this one:
https://gohugoio.netlify.app/maintenance/
I would like to build a shortcode for this.
Have you try where.
{{ range where site.RegularPages "Section" "maintenance" }}
{{ end }}
I didn’t test, there maybe typo.
Thank you, I will try to put something together from it
I solved my problem as follows.
I created a partial:
layouts/partials/last-updated-docs-list.html
with the following code:
{{ $all_pages := where .myStuff.Site.RegularPages "Section" .mySection }}
{{ $some_pages := where $all_pages "Params.excludefromstartpage" "ne" true }}
<ul class="list-unstyled">
{{ range first .myCount (sort $some_pages ".Lastmod" "desc") }}
<li><a class="no-underline" href="{{.Permalink}}">{{.Title}}</a></li>
{{ end }}
</ul>
This partial is called from the Startpage like so:
<h2 class="h4">Latest Updates</h2>
<b>Info</b>
{{ partial "last-updated-docs-list.html" (dict "myStuff" . "mySection" "info" "myCount" 2) }}
<b>Publikationen</b>
{{ partial "last-updated-docs-list.html" (dict "myStuff" . "mySection" "publications" "myCount" 2) }}
<b>Projekte</b>
{{ partial "last-updated-docs-list.html" (dict "myStuff" . "mySection" "projects" "myCount" 2) }}
<b>Portfolio</b>
{{ partial "last-updated-docs-list.html" (dict "myStuff" . "mySection" "portfolio" "myCount" 2) }}
I can exclude individual documents from the list by inserting excludefromstartpage
in the frontmatter of the document:
---
title: "Shall not show this"
excludefromstartpage: true
---
You can see this in action her: https://carsten-nichte.de
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.