mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
attachments: fix search dir and link if contentDir in multilang config is used #105
This commit is contained in:
parent
16b346c646
commit
a0e5194c00
3 changed files with 10 additions and 4 deletions
|
@ -0,0 +1 @@
|
|||
Harrr, nothn' to see herre
|
|
@ -2,4 +2,6 @@
|
|||
descrption = "Th' Attachments shorrrtcode displays a list o' files attached t' a plank"
|
||||
title = "Attachments"
|
||||
+++
|
||||
{{< piratify >}}
|
||||
{{% attachments /%}}
|
||||
|
||||
{{< piratify >}}
|
||||
|
|
|
@ -10,9 +10,12 @@
|
|||
{{- $filesName = printf "%s.files" .Page.File.BaseFileName }}
|
||||
{{- end}}
|
||||
|
||||
{{- $fileDir := replace .Page.File.Dir "\\" "/" }}
|
||||
{{- $fileLink := printf "%s/%s" (.Page.Language.ContentDir | default "content") .Page.File.Dir }}
|
||||
{{- $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 "content/%s%s" .Page.File.Dir $filesName) ) "Name" $sort }}
|
||||
{{- range sort (readDir (printf "%s%s" $fileDir $filesName) ) "Name" $sort }}
|
||||
{{- if findRE $pattern .Name}}
|
||||
{{- $size := .Size }}
|
||||
{{- $unit := "Byte-symbol" }}
|
||||
|
@ -25,7 +28,7 @@
|
|||
{{- $unit = "Megabyte-symbol" }}
|
||||
{{- end }}
|
||||
{{- $unitsymbol := $unit | T }}
|
||||
<li><a href="{{ (printf "%s%s/%s" $fileDir $filesName .Name) | relLangURL }}">{{.Name}}</a> ({{$size}} {{$unitsymbol}})</li>
|
||||
<li><a href="{{ (printf "%s%s/%s" $fileLink $filesName .Name) | relURL }}">{{.Name}}</a> ({{$size}} {{$unitsymbol}})</li>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue