Skip to content

Commit

Permalink
🐛 (linkpreview.html): fix potential nil pointer exception for default…
Browse files Browse the repository at this point in the history
…Noimage

♻️ (linkpreview.html): unescape HTML entities in title and description for better rendering
  • Loading branch information
russmckendrick committed Jun 23, 2024
1 parent 3fbc5fe commit fa65b0e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions layouts/shortcodes/linkpreview.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@
{{- end -}}
{{- end -}}
{{- else -}}
{{- $thumbnail := resources.Get $.Site.Params.defaultNoimage -}}
{{- $thumbnail_url = ($thumbnail.Fit (printf "800x400 center q%d webp" $imageQuality)).Permalink -}}
{{- with $thumbnail := resources.Get $.Site.Params.defaultNoimage -}}
{{- if $thumbnail -}}
{{- $thumbnail_url = ($thumbnail.Fit (printf "800x400 center q%d webp" $imageQuality)).Permalink -}}
{{- end -}}
{{- end -}}
{{- end -}}

<a href="{{- $url.String -}}" class="link-preview-card">
Expand All @@ -99,8 +102,8 @@
{{- end -}}
{{- end -}}
<div class="link-preview-content">
<div class="link-preview-title">{{- $title -}}</div>
<p class="link-preview-description">{{- $description | plainify | safeHTML -}}</p>
<div class="link-preview-title">{{- $title | htmlUnescape -}}</div>
<p class="link-preview-description">{{- $description | plainify | htmlUnescape | safeHTML -}}</p>
<div class="link-preview-meta">
<img src="{{ $faviconUrl }}" alt="favicon" class="link-preview-favicon no-zoom">
<span class="link-preview-domain">{{ $url.Host }}</span>
Expand Down

0 comments on commit fa65b0e

Please sign in to comment.