{{- $params := .Scratch.Get "params" -}}
{{- $expirationReminder := $params.expirationReminder | default dict -}}

{{- if $expirationReminder.enable -}}
  {{- $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="details admonition {{ $type }} open">
      <div class="details-summary admonition-title">
        <i class="icon fa-solid {{ $icon }} fa-fw" aria-hidden="true"></i>{{ T $type }}<i class="details-icon fa-solid fa-angle-right fa-fw" aria-hidden="true"></i>
      </div>
      <div class="details-content">
        <div class="admonition-content">
          {{- with .Site.Params.dateformat | default "2006-01-02" | $updateTime.Format -}}
            {{- dict "Date" . | T "expirationReminder" -}}
          {{- end -}}
        </div>
      </div>
    </div>
  {{- end -}}
{{- end -}}
