{{ define "main" }}             <!-- List of all tags/categories -->

{{ $singular_term := .Data.Singular }}
{{ $plural_term   := .Data.Plural }}

{{ partial "header_image.html" . }}

{{ with .Content }}
    <h3>Content</h3>
    {{ . }}
{{ end }}

{{ if .Param .Type }}
    <!-- https://discourse.gohugo.io/t/solved-creating-index-md-for-taxonomyterm-pages-tags-categories-hangs-hugo/11121/13?u=kaushalmodi -->
    {{ errorf "You cannot have a taxonomyTerm Kind page of Type '%s' have the same taxonomy set in its front-matter. Hugo will infloop (because of the way the debugprint partial works)!!\n  e.g. do not set 'tags' for a 'tags' taxonomyTerm page!" .Type }}
{{ end }}

{{ with .Resources }}
    <hr />
    <h3 id="resources">Resources</h3>
    <ul>
	{{ range . }}
	    {{ if .RelPermalink }}
	        <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
	    {{ else }}
	        <li>{{ .ResourceType | title }} (no link, only embedded in page)</li>
	    {{ end }}
	{{ end }}
    </ul>
{{ end }}

<h1>Archive of posts, by {{ $singular_term }}</h1>
<ul>
    {{ range .Data.Terms.Alphabetical }}
        <li><a href="/{{ $plural_term }}/{{ .Name | urlize }}">{{ .Name }}</a> ({{ .Count }} entries)</li>
    {{ end }}
</ul>

{{ if (not ($.Param "disable_debug")) }}
    <hr>
    <a id="debug"></a>
    <h3 id="page-debug">Page (Debug)</h3>
    {{ partial "debugprint.html" . }}
    <h3 id="file-debug">File Object (Debug)</h3>
    {{ partial "debugprint.html" .File }}
    <h3 id="taxonomy-debug">Ordered Taxonomy (Debug)</h3>
    {{ partial "debugprint.html" .Data.Terms.Alphabetical }}
{{ end }}

{{ end }}
