attachments: fix build error since Hugo 0.112 #540

This commit is contained in:
Sören Weber 2023-05-25 12:40:48 +02:00
parent a135b2adb4
commit 7daec21538
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -32,10 +32,18 @@
<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 | markdownify }}</div> <div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ $title | markdownify }}</div>
<ul class="box-content attachments-files"> <ul class="box-content attachments-files">
{{- $fileLink := printf "%s/%s" (.Language.ContentDir | default "content") .File.Dir }} {{- $version := split hugo.Version "." }}
{{- $fileLink = replace (replace $fileLink "\\" "/") "content/" "" }} {{- $major := int (index $version 0) }}
{{- $fileDir := printf "%s/%s" (.Language.ContentDir | default "content") .File.Dir }} {{- $minor := int (index $version 1) }}
{{- $fileDir = replace $fileDir "\\" "/" }} {{- $fileDir := "" }}
{{- if or (and (eq $major 0) (ge $minor 112)) (gt $major 0) }}
{{- $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)) }}
{{- $fileLink := $fileDir }}
{{- $fileLink = replace $fileLink "/content/" "" }}
{{- $filesName := printf "%s.files" .File.BaseFileName }} {{- $filesName := printf "%s.files" .File.BaseFileName }}
{{- if and (eq .File.BaseFileName "index") (fileExists (printf "%sfiles" $fileDir)) }} {{- if and (eq .File.BaseFileName "index") (fileExists (printf "%sfiles" $fileDir)) }}
{{- $c := "" }}{{/* backward compat to < 5.9.0 behavior */}} {{- $c := "" }}{{/* backward compat to < 5.9.0 behavior */}}