Hi!
I’m quite new to Hugo and super new to this community so please bare with me :).
I found this quite handy shortcode for generating a list of PDFs in a directory. Thank you peaceiris.
What I would like to do is to populate these files into a table.
I use the wonderful terrassa theme.
I have made some customization in a custom.css file, for tables among other things.
How should I proceed if I instead generating a list of pdf’s, put it in a table?
I’m all new to this but am I on deep water if I think that I could do something like this?
<!-- layouts/shortcodes/list-files.html -->
{{ $dir := .Get "dir" }}
{{ $regexp := .Get "regexp" }}
{{ range sort (readDir (delimit (slice "static" $dir) "/")) "Name" }}
{{ if (findRE $regexp .Name) }}
<table>
<thead>
<tr>
<a href="{{ $dir }}/{{ .Name }}">{{ .Name }}</a>
</tr>
</tr>
</thead>
</table>
{{ end }}
{{ end }}
Edit:
Another question. What I will do is to post pdfs every month and I name them .pdf. Now, sorting becomes a problem as it will take April first and September last.
I could of course solve it by renaming them 2020-02.pdf or something like that.
Any suggestions much appreciated
Regards