support for images in page bundles as relative paths

This commit is contained in:
Gabriele Musco 2022-10-24 08:02:44 +02:00
parent bedcf7a212
commit e4a10bab22
No known key found for this signature in database
GPG key ID: 1068D795C80E51DE
7 changed files with 55 additions and 11 deletions

View file

@ -1,5 +1,13 @@
<div class="featured postlist gridView">
{{ range . }}
{{ $image := "" }}
{{ if .Params.Image }}
{{ if or (hasPrefix .Params.Image "/") (hasPrefix .Params.Image "http://") (hasPrefix .Params.Image "https://") }}
{{ $image = .Params.Image }}
{{ else }}
{{ $image = path.Join "/" (path.Join .File.Dir .Params.Image) }}
{{ end }}
{{ end }}
<a class="featuredCardLink" href="{{ .Permalink }}">
<article class="featuredCard"
style="
@ -7,7 +15,7 @@
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.1) 45%,
rgba(0, 0, 0, 0.7) 100%
), url('{{ .Params.Image }}');
), url('{{ $image }}');
">
<div class="contentArea">
<h2>{{ .Title }}</h2>