aboutsummaryrefslogtreecommitdiff
path: root/layouts/partials/post/outdated-info-warning.html
blob: 3736c134116017a9d04409fade6b401b59b5f11f (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
{{- if or .Params.enableOutdatedInfoWarning (and .Site.Params.outdatedInfoWarning.enable (ne .Params.enableOutdatedInfoWarning false)) }}
  {{- $daysAgo := div (sub now.Unix .Lastmod.Unix) 86400 }}
  {{- $hintThreshold := .Site.Params.outdatedInfoWarning.hint | default 30 }}
  {{- $warnThreshold := .Site.Params.outdatedInfoWarning.warn | default 180 }}

  {{- $updateTime := .Lastmod }}
  {{- if .GitInfo }}
    {{- if lt .GitInfo.AuthorDate.Unix .Lastmod.Unix }}
      {{- $updateTime := .GitInfo.AuthorDate }}
    {{- end }}
  {{- end -}}

  {{- if gt $daysAgo $hintThreshold }}
  <div class="post-outdated">
    {{- if gt $daysAgo $warnThreshold }}
    <div class="warn">
    {{- else }}
    <div class="hint">
    {{- end }}
      <p>{{ T "outdatedInfoWarningBefore" -}}
        <span class="timeago" datetime="{{ dateFormat "2006-01-02T15:04:05" $updateTime }}" title="{{ dateFormat "January 2, 2006" $updateTime }}">
        {{- dateFormat "January 2, 2006" $updateTime -}}
        </span>{{ T "outdatedInfoWarningAfter" -}}
      </p>
    </div>
  </div>
  {{- end -}}
{{- end -}}