summaryrefslogtreecommitdiffstats
path: root/layouts/_partials/asset_table.html
blob: 116b22d029874a88d1ff251dbebe59d8d7640d73 (plain) (blame)
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
29
30
31
32
{{- /*
For a given collection of global resources, render a table with
the modification date of each resource and a link to the resource.
The resources must be from the assets/ directory in order to get their
modification times.

@context {,} resource.Resources

@example: {{ partial "asset_table.html" (resources.Match "spreadsheets/*.ods") }}
*/}}

<table>
  <thead>
    <tr>
      <th>Mod. date</th>
      <th>File</th>
    </tr>
  </thead>
  <tbody>
  {{ range . }}
    {{- $fpath := printf "assets/%s" .Name -}}
    <tr>
      <td>
      {{- with os.Stat $fpath -}}
        {{- .ModTime | time.Format "2006-01-02" -}}
      {{- end -}}
      </td>
      <td><a href="{{ .RelPermalink }}">{{ path.Base .Name }}</a></td>
    </tr>
  {{- end }}
  </tbody>
</table>