Populate files into a table

Hi! :wave:
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 :slight_smile:

Regards

Hey man! I am also new to Hugo. What I did was that I used @peaceiris shortcode and put it in a table using markdown table syntax, so it would be

| Subject |
|---|
|{{< list-files dir="Folder1" regexp=".pdf$" >}}   |

Maybe this can be of help to you

Forgot to add that I had to add a
in the shortcode for it to line up

Thank you boof for your reply!
Yes, I got how I add tables through markdown and how I use the shortcode.

I’ll try to explain better and it’s said that a picture says more than thousand words so I will upload a picture that might might it more clear :slight_smile:

So basically, instead of simple links to the documents (to the left in the picture), they should generate a table (to the right in the picture).
As a newcomer to hugo but not entierly to programming, I’m thinking this should be possible?
Only I’m not sure where to start :confused: