summaryrefslogtreecommitdiffstats
path: root/layouts/_partials
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/_partials')
-rw-r--r--layouts/_partials/asset_table.html32
1 files changed, 32 insertions, 0 deletions
diff --git a/layouts/_partials/asset_table.html b/layouts/_partials/asset_table.html
new file mode 100644
index 0000000..116b22d
--- /dev/null
+++ b/layouts/_partials/asset_table.html
@@ -0,0 +1,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>