summaryrefslogtreecommitdiffstats
path: root/layouts/partials/mini-toc.html
blob: 2681da44fdd85aa5f2052dc36d12d76cd71d3dea (plain)
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
{{/* Define a section to pull recent posts from.
    This will default to the section with the most number of pages. */}}
{{ $mainSections := site.Params.mainSections | default (slice "posts") }}

{{/* Create a variable with that section to use in multiple places. */}}
{{ $section := where site.RegularPages.ByDate.Reverse "Section" "in" $mainSections }}

{{/* Check to see if the section is defined for ranging through it */}}
{{ $sectionCount := len $section }}

{{ if ge $sectionCount 1 }}
    {{ $maxPosts := site.Params.recentPostsSize | default 5 }}

    <div class="toc" role="navigation">
        <h2>{{ i18n "latest_publications" }}</h2>
        <ul class="texts">
            {{/* Range through the first $maxPosts items of the $section */}}
            {{ range (first $maxPosts $section) }}
                <li class="text-title">
                    {{ partial "post-toc-summary" . }}
                </li>
            {{ end }}
        </ul>

        {{ if gt $sectionCount $maxPosts }}
        <p>
            <a href="{{ relref . "all-posts" }}">
                {{ i18n "all_publications" }}
                <span aria-hidden="true">&rarr;</span>
            </a>
        </p>
        {{ end }}
    </div>
{{ end }}