attachments.html 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <section class="attachments {{ with .Get "style"}}{{.}}{{ end }}">
  2. <label>
  3. <i class="fas fa-paperclip" aria-hidden="true"></i>
  4. {{with .Get "title"}}{{.}}{{else}}{{T "Attachments-label"}}{{end}}
  5. </label>
  6. {{if eq .Page.File.BaseFileName "index"}}
  7. {{$.Scratch.Add "filesName" "files"}}
  8. {{else}}
  9. {{$.Scratch.Add "filesName" (printf "%s.files" .Page.File.BaseFileName)}}
  10. {{end}}
  11. <div class="attachments-files">
  12. {{ range (readDir (printf "./content/%s%s" .Page.File.Dir ($.Scratch.Get "filesName")) ) }}
  13. {{ $fileDir := replace $.Page.File.Dir "\\" "/" }}
  14. {{if ($.Get "pattern")}}
  15. {{if (findRE ($.Get "pattern") .Name)}}
  16. <li>
  17. <a href="{{ (printf "%s%s/%s" $fileDir ($.Scratch.Get "filesName") .Name) | relURL }}" >
  18. {{.Name}}
  19. </a>
  20. ({{div .Size 1024 }} ko)
  21. </li>
  22. {{end}}
  23. {{else}}
  24. <li>
  25. <a href="{{ (printf "%s%s/%s" $fileDir ($.Scratch.Get "filesName") .Name) | relURL }}" >
  26. {{.Name}}
  27. </a>
  28. ({{div .Size 1024 }} ko)
  29. </li>
  30. {{end}}
  31. {{end}}
  32. <div>
  33. {{.Inner}}
  34. </section>