Replace use of add with path.Join for buildig paths.

This commit is contained in:
Fredrik Jonsson 2022-07-19 14:56:32 +02:00
commit 56d3c30a98
6 changed files with 13 additions and 13 deletions

View file

@ -1,6 +1,6 @@
{{ $src := (.Params.podcast.mp3 | absURL) -}}
{{ if site.Params.Podcast.cdn -}}
{{ $src = add site.Params.Podcast.cdn (.Params.podcast.mp3 | relURL) -}}
{{ $src = path.Join site.Params.Podcast.cdn (.Params.podcast.mp3 | relURL) -}}
{{ end -}}
<figure class="podcast">
<audio controls preload="{{ site.Params.Podcast.preload | default "metadata" }}"><source src="{{ $src }}" type="audio/mpeg"></audio>

View file

@ -49,9 +49,9 @@
{{ end -}}
<description>{{ .Content | html }}</description>
{{ if site.Params.Podcast.local | default true -}}
{{ with .Params.podcast.mp3 }}{{ $file_stat := os.Stat (add "/static" (. | relURL)) }}<enclosure url="{{ if site.Params.Podcast.cdn }}{{ add site.Params.Podcast.cdn (. | relURL) }}{{ else }}{{ . | absURL }}{{ end }}" length="{{ $file_stat.Size }}" type="audio/mpeg" />{{ end }}
{{ with .Params.podcast.mp3 }}{{ $file_stat := os.Stat (path.Join "/static" (. | relURL)) }}<enclosure url="{{ if site.Params.Podcast.cdn }}{{ path.Join site.Params.Podcast.cdn (. | relURL) }}{{ else }}{{ . | absURL }}{{ end }}" length="{{ $file_stat.Size }}" type="audio/mpeg" />{{ end }}
{{ else -}}
{{ with .Params.podcast.mp3 }}<enclosure url="{{ if site.Params.Podcast.cdn }}{{ add site.Params.Podcast.cdn (. | relURL) }}{{ else }}{{ . | absURL }}{{ end }}" type="audio/mpeg" />{{ end }}
{{ with .Params.podcast.mp3 }}<enclosure url="{{ if site.Params.Podcast.cdn }}{{ path.Join site.Params.Podcast.cdn (. | relURL) }}{{ else }}{{ . | absURL }}{{ end }}" type="audio/mpeg" />{{ end }}
{{ end -}}
{{ with .Params.podcast.duration }}<itunes:duration>{{ . }}</itunes:duration>{{ end }}
{{ with .Params.podcast.image.src }}{{ $image := resources.Get . }}<itunes:image href="{{ $image.Permalink }}" />{{ end }}

View file

@ -14,7 +14,7 @@
{{ $maxwidth := site.Params.imageMaxWidth -}}
{{ $realwidth := 0 -}}
{{ $realheight := 0 -}}
{{ if and $src (fileExists (add "/assets" $src)) -}}
{{ if and $src (fileExists (path.Join "/assets" $src)) -}}
{{ $original := resources.Get $src -}}
{{ if $size -}}
{{ $image := $original.Resize $size -}}
@ -34,8 +34,8 @@
{{ $width = "" -}}
{{ $height = "" -}}
{{ end -}}
{{ else if and $src (fileExists (add "/static" $src)) -}}
{{ with (imageConfig (add "/static" $src)) -}}
{{ else if and $src (fileExists (path.Join "/static" $src)) -}}
{{ with (imageConfig (path.Join "/static" $src)) -}}
{{ $realwidth = .Width -}}
{{ $realheight = .Height -}}
{{ end -}}

View file

@ -2,7 +2,7 @@
{{ $newtab := .Get "newtab" | default false -}}
{{ $src := .Get "src" -}}
{{ $text := .Get "text" -}}
{{ if and $src (fileExists (add "/assets" $src)) -}}
{{ if and $src (fileExists (path.Join "/assets" $src)) -}}
{{ $original := resources.Get $src -}}
{{ $src = $original.RelPermalink -}}
{{ end -}}

View file

@ -10,7 +10,7 @@
{{ $maxwidth := site.Params.imageMaxWidth -}}
{{ $realwidth := 0 -}}
{{ $realheight := 0 -}}
{{ if and $src (fileExists (add "/assets" $src)) -}}
{{ if and $src (fileExists (path.Join "/assets" $src)) -}}
{{ $original := resources.Get $src -}}
{{ if $size -}}
{{ $image := $original.Resize $size -}}
@ -30,8 +30,8 @@
{{ $width = "" -}}
{{ $height = "" -}}
{{ end -}}
{{ else if and $src (fileExists (add "/static" $src)) -}}
{{ with (imageConfig (add "/static" $src)) -}}
{{ else if and $src (fileExists (path.Join "/static" $src)) -}}
{{ with (imageConfig (path.Join "/static" $src)) -}}
{{ $realwidth = .Width -}}
{{ $realheight = .Height -}}
{{ end -}}

View file

@ -6,15 +6,15 @@
{{ $link := .Get "link" -}}
{{ $src := .Get "src" -}}
{{ $width := .Get "width" -}}
{{ if and $src (fileExists (add "/assets" $src)) -}}
{{ if and $src (fileExists (path.Join "/assets" $src)) -}}
{{ $original := resources.Get $src -}}
{{ if $inline -}}
{{ $src = $original.Content -}}
{{ else -}}
{{ $src = $original.RelPermalink -}}
{{ end -}}
{{ else if and $src $inline (fileExists (add "/static" $src)) -}}
{{ $src = readFile (add "/static" $src) -}}
{{ else if and $src $inline (fileExists (path.Join "/static" $src)) -}}
{{ $src = readFile (path.Join "/static" $src) -}}
{{ end -}}
{{ if and $width $height -}}
{{ $width = int $width -}}