mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
attachments: don't break build if directory wasn't found #480
This commit is contained in:
parent
686c013ef5
commit
472176a88c
1 changed files with 18 additions and 16 deletions
|
@ -39,23 +39,25 @@
|
|||
{{- $filesName = "files" }}
|
||||
{{- end }}
|
||||
{{- $dir := printf "%s%s" $fileDir $filesName }}
|
||||
{{- range sort (readDir $dir) "Name" $sort }}
|
||||
{{- if findRE $pattern .Name}}
|
||||
{{- $size := .Size }}
|
||||
{{- $unit := "Byte-symbol" }}
|
||||
{{- if ge $size 1024 }}
|
||||
{{- $size = div $size 1024 }}
|
||||
{{- $unit = "Kilobyte-symbol" }}
|
||||
{{- if fileExists $dir }}
|
||||
{{- range sort (readDir $dir) "Name" $sort }}
|
||||
{{- if findRE $pattern .Name}}
|
||||
{{- $size := .Size }}
|
||||
{{- $unit := "Byte-symbol" }}
|
||||
{{- if ge $size 1024 }}
|
||||
{{- $size = div $size 1024 }}
|
||||
{{- $unit = "Kilobyte-symbol" }}
|
||||
{{- end }}
|
||||
{{- if ge $size 1024 }}
|
||||
{{- $size = div $size 1024 }}
|
||||
{{- $unit = "Megabyte-symbol" }}
|
||||
{{- end }}
|
||||
{{- $unitsymbol := $unit | T }}
|
||||
{{- $link := (printf "%s%s/%s" $fileLink $filesName .Name) | relLangURL }}
|
||||
{{- $c := "" }}{{/* Hugo stores the attachments always in the default language subdirectory */}}
|
||||
{{- $link = replace $link $urlPrefix $defaultUrlPrefix 1 }}
|
||||
<li><a href="{{ $link }}">{{.Name}}</a> ({{$size}} {{$unitsymbol}})</li>
|
||||
{{- end }}
|
||||
{{- if ge $size 1024 }}
|
||||
{{- $size = div $size 1024 }}
|
||||
{{- $unit = "Megabyte-symbol" }}
|
||||
{{- end }}
|
||||
{{- $unitsymbol := $unit | T }}
|
||||
{{- $link := (printf "%s%s/%s" $fileLink $filesName .Name) | relLangURL }}
|
||||
{{- $c := "" }}{{/* Hugo stores the attachments always in the default language subdirectory */}}
|
||||
{{- $link = replace $link $urlPrefix $defaultUrlPrefix 1 }}
|
||||
<li><a href="{{ $link }}">{{.Name}}</a> ({{$size}} {{$unitsymbol}})</li>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue