From a0e5194c0027d1678bf04c61c1cce8a018bf9d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Tue, 28 Sep 2021 21:24:30 +0200 Subject: [PATCH] attachments: fix search dir and link if contentDir in multilang config is used #105 --- .../shortcodes/attachments.pir.files/NoTreasure.txt | 1 + exampleSite/content/shortcodes/attachments.pir.md | 4 +++- layouts/shortcodes/attachments.html | 9 ++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 exampleSite/content/shortcodes/attachments.pir.files/NoTreasure.txt diff --git a/exampleSite/content/shortcodes/attachments.pir.files/NoTreasure.txt b/exampleSite/content/shortcodes/attachments.pir.files/NoTreasure.txt new file mode 100644 index 0000000000..f7b9fda214 --- /dev/null +++ b/exampleSite/content/shortcodes/attachments.pir.files/NoTreasure.txt @@ -0,0 +1 @@ +Harrr, nothn' to see herre \ No newline at end of file diff --git a/exampleSite/content/shortcodes/attachments.pir.md b/exampleSite/content/shortcodes/attachments.pir.md index e9e50df62c..da31540ccc 100644 --- a/exampleSite/content/shortcodes/attachments.pir.md +++ b/exampleSite/content/shortcodes/attachments.pir.md @@ -2,4 +2,6 @@ descrption = "Th' Attachments shorrrtcode displays a list o' files attached t' a plank" title = "Attachments" +++ -{{< piratify >}} \ No newline at end of file +{{% attachments /%}} + +{{< piratify >}} diff --git a/layouts/shortcodes/attachments.html b/layouts/shortcodes/attachments.html index d348f395cc..0c17506257 100644 --- a/layouts/shortcodes/attachments.html +++ b/layouts/shortcodes/attachments.html @@ -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 }} -
  • {{.Name}} ({{$size}} {{$unitsymbol}})
  • +
  • {{.Name}} ({{$size}} {{$unitsymbol}})
  • {{- end }} {{- end }}