mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-18 10:50:24 +00:00
attachments: sort output #23
This commit is contained in:
parent
c62a9d1958
commit
bb5541f791
2 changed files with 4 additions and 3 deletions
|
@ -38,7 +38,8 @@ That's all!
|
|||
| Parameter | Default | Description |
|
||||
|:--|:--|:--|
|
||||
| title | "Attachments" | List's title |
|
||||
| style | "" | Choose between "orange", "grey", "blue" and "green" for nice style |
|
||||
| sort | "asc" | Sorting the output in `asc`ending or `desc`ending order |
|
||||
| style | "" | Choose between `orange`, `grey`, `blue` and `green` for nice style |
|
||||
| pattern | ".*" | A regular expressions, used to filter the attachments by file name. <br/><br/>The **pattern** parameter value must be [regular expressions](https://en.wikipedia.org/wiki/Regular_expression).
|
||||
|
||||
For example:
|
||||
|
@ -50,7 +51,6 @@ For example:
|
|||
|
||||
#### List of attachments ending in pdf or mp4
|
||||
|
||||
|
||||
{{%/*attachments title="Related files" pattern=".*(pdf|mp4)"/*/%}}
|
||||
|
||||
renders as
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{{ $_hugo_config := `{ "version": 1 }` }}
|
||||
{{ $style := .Get "style" | default "neutral" }}
|
||||
{{ $title := .Get "title" | default ("Attachments-label" | T) }}
|
||||
{{ $sort := .Get "sort" | default "asc" }}
|
||||
<section class="attachments {{ $style }}">
|
||||
<div class="label">{{ $title }}</div>
|
||||
<div class="attachments-files">
|
||||
|
@ -11,7 +12,7 @@
|
|||
|
||||
{{- $fileDir := replace .Page.File.Dir "\\" "/" }}
|
||||
{{- $pattern := .Get "pattern" | default "" }}
|
||||
{{- range (readDir (printf "content/%s%s" .Page.File.Dir $filesName) ) }}
|
||||
{{- range sort (readDir (printf "content/%s%s" .Page.File.Dir $filesName) ) "Name" $sort }}
|
||||
{{- if findRE $pattern .Name}}
|
||||
{{- $size := .Size }}
|
||||
{{- $unit := "Byte-symbol" }}
|
||||
|
|
Loading…
Reference in a new issue