Add SVG support to article featured images

pull/441/head
James Panther 2023-01-15 10:38:53 +11:00
parent b9bb291a8d
commit 7e970f4c97
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
6 changed files with 60 additions and 25 deletions

View File

@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Added ### Added
- Front matter support for specifying article thumbnails, covers and featured image details (including filename pattern, alt text and caption) - Front matter support for specifying article thumbnails, covers and featured image details (including filename pattern, alt text and caption)
- Support for SVG assets as article thumbnails, covers and featured images
- Front matter keywords support on a per article basis - Front matter keywords support on a per article basis
- Indonesian translation ([#398](https://github.com/jpanther/congo/pull/398)) - Indonesian translation ([#398](https://github.com/jpanther/congo/pull/398))
- Mastodon sharing links ([#405](https://github.com/jpanther/congo/pull/405)) - Mastodon sharing links ([#405](https://github.com/jpanther/congo/pull/405))

View File

@ -1890,6 +1890,10 @@ body:has(#menu-controller:checked) {
height: 9rem; height: 9rem;
} }
.max-h-\[4\.5rem\] {
max-height: 4.5rem;
}
.max-h-\[10rem\] { .max-h-\[10rem\] {
max-height: 10rem; max-height: 10rem;
} }
@ -1950,6 +1954,10 @@ body:has(#menu-controller:checked) {
max-width: 65ch; max-width: 65ch;
} }
.max-w-\[6rem\] {
max-width: 6rem;
}
.max-w-\[10rem\] { .max-w-\[10rem\] {
max-width: 10rem; max-width: 10rem;
} }
@ -2883,6 +2891,10 @@ body:has(#menu-controller:checked) {
display: none; display: none;
} }
.sm\:max-h-\[7\.5rem\] {
max-height: 7.5rem;
}
.sm\:w-1\/2 { .sm\:w-1\/2 {
width: 50%; width: 50%;
} }
@ -2891,6 +2903,10 @@ body:has(#menu-controller:checked) {
width: 10rem; width: 10rem;
} }
.sm\:max-w-\[10rem\] {
max-width: 10rem;
}
.sm\:flex-row { .sm\:flex-row {
flex-direction: row; flex-direction: row;
} }

View File

@ -17,7 +17,10 @@
<figure> <figure>
<img <img
class="mx-auto my-0 rounded-md" class="mx-auto my-0 rounded-md"
{{ if or (lt .Width 660) (eq .MediaType.SubType "svg") }} {{ if eq .MediaType.SubType "svg" }}
src="{{ .RelPermalink }}"
{{ else }}
{{ if lt .Width 660 }}
src="{{ .RelPermalink }}" src="{{ .RelPermalink }}"
{{ else }} {{ else }}
srcset=" srcset="
@ -27,6 +30,7 @@
{{ (.Resize "1320x").RelPermalink }} 2x" {{ (.Resize "1320x").RelPermalink }} 2x"
src="{{ (.Resize "660x").RelPermalink }}" src="{{ (.Resize "660x").RelPermalink }}"
{{ end }} {{ end }}
{{ end }}
alt="{{ $altText }}" alt="{{ $altText }}"
/> />
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }} {{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}

View File

@ -17,12 +17,18 @@
<div class="prose"> <div class="prose">
<img <img
class="mb-6 -mt-4 rounded-md" class="mb-6 -mt-4 rounded-md"
srcset=" {{ if eq .MediaType.SubType "svg" }}
{{- (.Resize "330x").RelPermalink }} 330w, src="{{ .RelPermalink }}"
{{- (.Resize "660x").RelPermalink }} 660w, {{ else }}
{{- (.Resize "1024x").RelPermalink }} 1024w, {{ if lt .Width 660 }}
{{- (.Resize "1320x").RelPermalink }} 2x" src="{{ .RelPermalink }}"
{{ else }}
srcset=" {{ (.Resize "330x").RelPermalink }} 330w,
{{ (.Resize "660x").RelPermalink }} 660w, {{ (.Resize "1024x").RelPermalink }}
1024w, {{ (.Resize "1320x").RelPermalink }} 2x"
src="{{ (.Resize "660x").RelPermalink }}" src="{{ (.Resize "660x").RelPermalink }}"
{{ end }}
{{ end }}
alt="{{ $.Params.featureAlt | default $.Params.coverAlt | default "" }}" alt="{{ $.Params.featureAlt | default $.Params.coverAlt | default "" }}"
/> />
{{ with $.Params.coverCaption }} {{ with $.Params.coverCaption }}

View File

@ -13,12 +13,16 @@
aria-label="{{ $.Title | emojify }}" aria-label="{{ $.Title | emojify }}"
> >
<img <img
class="w-24 rounded-md sm:w-40"
srcset="
{{- (.Fill "160x120 smart").RelPermalink }} 160w,
{{- (.Fill "320x240 smart").RelPermalink }} 2x"
src="{{ (.Fill "160x120 smart").RelPermalink }}"
alt="{{ $.Params.featureAlt | default $.Params.thumbnailAlt | default "" }}" alt="{{ $.Params.featureAlt | default $.Params.thumbnailAlt | default "" }}"
{{ if eq .MediaType.SubType "svg" }}
class="w-24 max-w-[6rem] max-h-[4.5rem] rounded-md sm:max-h-[7.5rem] sm:w-40
sm:max-w-[10rem]" src="{{ .RelPermalink }}"
{{ else }}
class="w-24 rounded-md sm:w-40" srcset="
{{- (.Fill "160x120 smart").RelPermalink }}
160w, {{- (.Fill "320x240 smart").RelPermalink }} 2x"
src="{{ (.Fill "160x120 smart").RelPermalink }}"
{{ end }}
/> />
</a> </a>
</div> </div>

View File

@ -21,7 +21,10 @@
{{ $resource = resources.Get ($url.String) }} {{ $resource = resources.Get ($url.String) }}
{{ end }} {{ end }}
{{ with $resource }} {{ with $resource }}
{{ if or (lt .Width 660) (eq .MediaType.SubType "svg") }} {{ if eq .MediaType.SubType "svg" }}
src="{{ .RelPermalink }}"
{{ else }}
{{ if lt .Width 660 }}
src="{{ .RelPermalink }}" src="{{ .RelPermalink }}"
{{ else }} {{ else }}
srcset=" srcset="
@ -31,6 +34,7 @@
{{ (.Resize "1320x").RelPermalink }} 2x" {{ (.Resize "1320x").RelPermalink }} 2x"
src="{{ (.Resize "660x").RelPermalink }}" src="{{ (.Resize "660x").RelPermalink }}"
{{ end }} {{ end }}
{{ end }}
{{ else }} {{ else }}
src="{{ $url.String }}" src="{{ $url.String }}"
{{ end }} {{ end }}