attachments: adjust implementation to doc #252

This commit is contained in:
Sören Weber 2022-05-25 23:37:44 +02:00
parent 2271ff4611
commit f595aaa287
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
2 changed files with 5 additions and 5 deletions

View file

@ -62,14 +62,14 @@ Be aware that if you use a multilingual website, you will need to have as many f
{{% /expand %}}
### Colored styled box, descending sort order
### Info styled box, descending sort order
{{% attachments style="orange" sort="desc" /%}}
{{% attachments style="info" sort="desc" /%}}
{{% expand "Show markup" %}}
````go
{{%/* attachments style="orange" sort="desc" /*/%}}
{{%/* attachments style="info" sort="desc" /*/%}}
````
{{% /expand %}}

View file

@ -1,6 +1,6 @@
{{- $_hugo_config := `{ "version": 1 }` }}
{{- $style := .Get "style" | default "transparent" }}
{{- $title := .Get "title" | default ("Attachments-label" | T) }}
{{- $title := .Get "title" | default ($style | T) | default ("Attachments-label" | T) }}
{{- $icon := .Get "icon" | default "" }}
{{- if and (not $icon) (eq (len $icon) 0) }}
{{- $icon = "paperclip" }}
@ -11,6 +11,7 @@
{{- end }}
{{- $icon = trim $icon " " }}
{{- $sort := .Get "sort" | default "asc" }}
{{- $pattern := .Get "pattern" | default "" }}
<div class="box attachments {{ $style }}">
<div class="box-label">{{ if $icon }}<i class="fas fa-{{ $icon }} fa-fw"></i> {{ end }}{{ $title }}</div>
<ul class="box-content attachments-files">
@ -22,7 +23,6 @@
{{- $fileLink = replace (replace $fileLink "\\" "/") "content/" "" }}
{{- $fileDir := printf "%s/%s" (.Page.Language.ContentDir | default "content") .Page.File.Dir }}
{{- $fileDir = replace $fileDir "\\" "/" }}
{{- $pattern := .Get "pattern" | default "" }}
{{- range sort (readDir (printf "%s%s" $fileDir $filesName) ) "Name" $sort }}
{{- if findRE $pattern .Name}}
{{- $size := .Size }}