Within a list page at https://domain.com/university
I list all the modules I participate in.
The basic file hierarchy looks something like that:
content/
├── about.md
└── university
├── 2101-mathematik-1
│ ├── 07-10-2021.md
│ └── _index.md
├── 2102-einfuehrung-in-die-informatik-1
│ └── _index.md
├── 2103-digital-business
│ ├── 08-10-2021.md
│ └── _index.md
├── 2104-mathematik-3-stochastik-statistik
│ └── _index.md
└── _index.md
I want to sort the subfolders under university/
by the newest post appearing in them. If a new post is added to a folder currently on the bottom of the page, it should move to the top.
Currently I use this code snipped within layouts/section/university.html
:
{{ define "main" }}
<h1 class="page-title">{{ .Title }}</h1>
{{ range (site.GetPage "university").Sections }} <!-- .ByDate.Reverse -->
<ul>
{{ range .Pages}}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
{{ end }}
This currently just sorts the folders by name.
I cannot just change
{{ range (site.GetPage "university").Sections }}
to
{{ range (site.GetPage "university").Sections.ByDate.Reverse }}
as this refers back to the folder, not the posts within them.
If someone got any idea, I would be glad to hear it!
You can have a look how it looks in action on: https://lucaschulz.xyz/university