{{- $params := partial "function/params.html" -}}
{{- $expirationReminder := $params.expirationReminder | default dict -}}
{{- $isEnabled := $expirationReminder.enable | and (not $params.password) -}}

{{- if $isEnabled -}}
  {{- $daysAgo := div (sub now.Unix .Lastmod.Unix) 86400 }}
  {{- $reminderThreshold := $expirationReminder.reminder | default 90 }}
  {{- $warningThreshold := $expirationReminder.warning | default 180 }}
  {{- $updateTime := .Lastmod }}

  {{- if gt $daysAgo $reminderThreshold -}}
    {{- $type := "note" -}}
    {{- $icon := "fa-pencil-alt" -}}
    {{- if gt $daysAgo $warningThreshold -}}
      {{- $type = "warning" -}}
      {{- $icon = "fa-exclamation-triangle" -}}
    {{- end -}}
    <div class="expiration-reminder details admonition {{ $type }} open">
      <div class="details-summary admonition-title">
        <i class="icon fa-solid {{ $icon }}" aria-hidden="true"></i>{{ T (printf "admonition.%v" $type) }}<i class="details-icon fa-solid fa-angle-right" aria-hidden="true"></i>
      </div>
      <div class="details-content">
        <div class="admonition-content">
          {{- with $updateTime | dateFormat (.Site.Params.dateformat | default "2006-01-02") -}}
            {{- dict "Date" . | T "single.expirationReminder" -}}
          {{- end -}}
        </div>
      </div>
    </div>
  {{- end -}}
{{- end -}}
