{{ define "title" }}{{ if .Items }}({{ len .Items }}) {{ end }}Intake{{ end }}

{{ define "buttons" -}}
<button class="item-button" title="Deactivate {{ .Source }}/{{ .Id }}">&#10005;</button>
<button class="item-button" title="Punt {{ .Source }}/{{ .Id }}">&#8631;</button>
{{- if .Link }}<a class="item-link" href="{{ .Link }}" target="_blank">&#8663;</a>
{{ end -}}
{{ end }}

{{ define "item-title" -}}
<span class="item-title">{{ or .Title .Id | raw }}</span>
{{- end }}

{{ define "content" -}}
<article class="center">
<span class="item-title">
<a href="#">Home</a>
[<a href="#">Active</a> | <a href="#">All</a>]
</span>
</article>

{{ if .Items }}
{{ range .Items }}
	<article id="{{ .Source }}-{{ .Id }}">

	{{/* The item title is a clickable <summary> if there is body content */}}
    {{ if .Body }}
    <details>
    <summary>
        {{ template "buttons" . }}
        {{ template "item-title" . }}
    </summary>
	{{ if .Body }}
	<p>{{ raw .Body }}</p>
	{{ end }}
	</details>
	{{ template "buttons" . }}
	{{ else }}
	{{ template "buttons" . }}
    {{ template "item-title" . }}<br>
	{{ end }}
    {{/* end if .Body */}}

    {{/* author/time footer line */}}
	{{ if or .Author .Time }}
	<span class="item-info">
	{{ .Author }}
	{{ .Time | tsToDate }}
	</span><br>
	{{ end }}

    {{/* source/id/created footer line */}}
	<span class="item-info">
    {{ .Source }}/{{ .Id }}
    {{ .Created | tsToDate }}
	</span>

	</article>
{{ end }}
{{/* end range .Items */}}

<article class="center">
<button>Deactivate All</button>
</article>

{{/* if .Items */}}
{{ else }}
<article class="center">
    <span class="item-title">Feed is empty</span>
</article>
{{ end }}
{{/* end if .Items */}}

{{ end }}
{{/* end define "content" */}}