attachments: remove warnings for unsupported Hugo versions #825

This commit is contained in:
Sören Weber 2024-04-07 22:45:00 +02:00
parent 7c9f145e93
commit 43e9a8c376
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -41,23 +41,12 @@
{{- $urlPrefix := strings.TrimRight "/" $page.RelPermalink }} {{- $urlPrefix := strings.TrimRight "/" $page.RelPermalink }}
{{- with $page }} {{- with $page }}
{{- if ne .BundleType "leaf" }} {{- if ne .BundleType "leaf" }}
{{- $hugoVersion := "0.112.0" }} {{- warnf "%q: UNSUPPORTED usage of 'attachments' shortcode found while using Hugo >= 0.112.0, use a leaf bundle instead; see https://mcshelby.github.io/hugo-theme-relearn/shortcodes/attachments/index.html#single-language" $page.File.Filename }}
{{- if ge hugo.Version $hugoVersion }}
{{- warnf "%q: UNSUPPORTED usage of 'attachments' shortcode found while using Hugo >= 0.112.0, use a leaf bundle instead; see https://mcshelby.github.io/hugo-theme-relearn/shortcodes/attachments/index.html#single-language" $page.File.Filename }}
{{- else }}
{{- warnf "%q: DEPRECATED usage of 'attachments' shortcode found which will not be compatible while using Hugo >= 0.112.0, use a leaf bundle instead; see https://mcshelby.github.io/hugo-theme-relearn/shortcodes/attachments/index.html#single-language" $page.File.Filename }}
{{- end }}
{{- end }} {{- end }}
<div class="box attachments cstyle {{ $style }}"{{ if $color }} style="--VARIABLE-BOX-color: {{ $color }};"{{ end }}> <div class="box attachments cstyle {{ $style }}"{{ if $color }} style="--VARIABLE-BOX-color: {{ $color }};"{{ end }}>
<div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ $title | .RenderString }}</div> <div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ $title | .RenderString }}</div>
<ul class="box-content attachments-files"> <ul class="box-content attachments-files">
{{- $fileDir := "" }} {{- $fileDir := path.Dir (strings.TrimPrefix (path.Clean hugo.WorkingDir) (path.Clean .File.Filename)) }}
{{- $hugoVersion := "0.112.0" }}
{{- if ge hugo.Version $hugoVersion }}
{{- $fileDir = path.Dir (strings.TrimPrefix (path.Clean hugo.WorkingDir) (path.Clean .File.Filename)) }}
{{- else }}
{{- $fileDir = printf "%s/%s" (path.Clean (.Language.ContentDir | default "content")) (path.Clean .File.Dir) }}
{{- end }}
{{- $fileDir = printf "%s/" (path.Clean (strings.TrimPrefix "/" $fileDir)) }} {{- $fileDir = printf "%s/" (path.Clean (strings.TrimPrefix "/" $fileDir)) }}
{{- $fileLink := $fileDir }} {{- $fileLink := $fileDir }}
{{- $fileLink = strings.TrimPrefix "content/" $fileLink }} {{- $fileLink = strings.TrimPrefix "content/" $fileLink }}