Skip to content

Commit 5f295a1

Browse files
fix: WebP conversion
1 parent 508869d commit 5f295a1

File tree

2 files changed

+6
-25
lines changed

2 files changed

+6
-25
lines changed

layouts/partials/basic-seo.html

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,7 @@
1717
<meta property="og:site_name" content="{{ site.Title }}" />
1818

1919
{{- with .Params.image -}}
20-
{{- $imageUrl := . -}}
21-
{{- if not (hasPrefix . "http") -}}
22-
{{- with resources.Get . -}}
23-
{{- $resized := .Fill "1200x630 webp q85" -}}
24-
{{- $imageUrl = $resized.Permalink -}}
25-
{{- else -}}
26-
{{- $imageUrl = . | absURL -}}
27-
{{- end -}}
28-
{{- end -}}
29-
<meta property="og:image" content="{{ $imageUrl }}" />
20+
<meta property="og:image" content="{{ . | absURL }}" />
3021
<meta property="og:image:width" content="1200" />
3122
<meta property="og:image:height" content="630" />
3223
{{- end -}}
@@ -37,14 +28,5 @@
3728
<meta name="twitter:title" content="{{ $title }}" />
3829
<meta name="twitter:description" content="{{ $description }}" />
3930
{{- with .Params.image -}}
40-
{{- $imageUrl := . -}}
41-
{{- if not (hasPrefix . "http") -}}
42-
{{- with resources.Get . -}}
43-
{{- $resized := .Fill "1200x630 webp q85" -}}
44-
{{- $imageUrl = $resized.Permalink -}}
45-
{{- else -}}
46-
{{- $imageUrl = . | absURL -}}
47-
{{- end -}}
48-
{{- end -}}
49-
<meta name="twitter:image" content="{{ $imageUrl }}" />
31+
<meta name="twitter:image" content="{{ . | absURL }}" />
5032
{{- end -}}

themes/hugoplate/layouts/partials/components/blog-card.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<div class="bg-body dark:bg-darkmode-body">
22
{{ $image:= .Params.image }}
33
{{ if $image }}
4-
{{ $imageUrl := $image }}
4+
{{- $imageUrl := $image | relURL -}}
55
{{- if not (hasPrefix $image "http") -}}
6-
{{- with resources.Get $image -}}
7-
{{- $resized := .Fill "400x234 webp q85" -}}
6+
{{- $resourcePath := strings.TrimPrefix "/" $image -}}
7+
{{- with resources.Get $resourcePath -}}
8+
{{- $resized := .Fill "400x234 q85" -}}
89
{{- $imageUrl = $resized.RelPermalink -}}
9-
{{- else -}}
10-
{{- $imageUrl = $image | relURL -}}
1110
{{- end -}}
1211
{{- end -}}
1312
<div

0 commit comments

Comments
 (0)