1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-23 21:02:09 +00:00

Don't include an unused png fallback for an SVG

No browser I know of falls back to a PNG when given an SVG with a PNG
fallback. The Tor version of my site uses no SVGs.

Exclude the SVG favicon in the Tor version of the site, since the Tor
Browser disables SVG on the safest setting.
This commit is contained in:
Rohan Kumar 2022-03-10 21:27:40 -08:00
parent f93637455d
commit ca07453315
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
3 changed files with 10 additions and 9 deletions

View file

@ -20,8 +20,11 @@
{{ if lt .Date .Lastmod -}} {{ if lt .Date .Lastmod -}}
<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}"> <meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}">
{{ end -}} {{ end -}}
<!--the Tor Browser's safest setting disables SVGs but still downloads them to avoid fingerprinting-->
{{ if (ne .Site.BaseURL "http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/") -}}
{{ $icon_svg := resources.Get "/favicon.svg" | resources.Fingerprint "md5" }} {{ $icon_svg := resources.Get "/favicon.svg" | resources.Fingerprint "md5" }}
{{- printf `<link rel="icon" sizes="any" href="%s" type="image/svg+xml">` $icon_svg.RelPermalink | safeHTML }} {{- printf `<link rel="icon" sizes="any" href="%s" type="image/svg+xml">` $icon_svg.RelPermalink | safeHTML }}
{{- fi }}
{{ $icon_192 := resources.Get "/apple-touch-icon.png" | resources.Fingerprint "md5" }} {{ $icon_192 := resources.Get "/apple-touch-icon.png" | resources.Fingerprint "md5" }}
{{- printf `<link rel="icon" sizes="192x192" href="%s" type="image/png">` $icon_192.RelPermalink | safeHTML -}} {{- printf `<link rel="icon" sizes="192x192" href="%s" type="image/png">` $icon_192.RelPermalink | safeHTML -}}
{{ $favicon := resources.Get "/favicon.png" -}} {{ $favicon := resources.Get "/favicon.png" -}}

View file

@ -25,7 +25,7 @@
--> -->
<span itemprop="author" itemscope itemtype="https://schema.org/Person" class="h-card p-author author vcard"> <span itemprop="author" itemscope itemtype="https://schema.org/Person" class="h-card p-author author vcard">
<a itemprop="url" href="https://seirdy.one" rel="author home cc:attributionURL" class="u-url url" property="cc:attributionName"> <a itemprop="url" href="https://seirdy.one" rel="author home cc:attributionURL" class="u-url url" property="cc:attributionName">
<img itemprop="image" class="u-photo photo" src="data:image/png;base64,{{ $favicon_base64 }}" alt="" width="16" height="16"> {{ partial "indieweb-icon.html" }}
<span itemprop="name" class="p-name fn n"> <span itemprop="name" class="p-name fn n">
<span itemprop="givenName" class="p-given-name given-name">Rohan</span> <span itemprop="givenName" class="p-given-name given-name">Rohan</span>
<span itemprop="familyName" class="p-family-name family-name">Kumar</span></span></a> <span itemprop="familyName" class="p-family-name family-name">Kumar</span></span></a>

View file

@ -2,12 +2,10 @@
{{- $favicon_base64 := $favicon.Content | base64Encode -}} {{- $favicon_base64 := $favicon.Content | base64Encode -}}
{{- $favicon_svg := resources.Get "/favicon.svg" | resources.Fingerprint "md5" -}} {{- $favicon_svg := resources.Get "/favicon.svg" | resources.Fingerprint "md5" -}}
{{- $favicon_bigpng := resources.Get "/apple-touch-icon.png" | resources.Fingerprint "md5" -}} {{- $favicon_bigpng := resources.Get "/apple-touch-icon.png" | resources.Fingerprint "md5" -}}
{{- if (ne .Site.BaseURL "http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/") -}} <img itemprop="image" class="u-photo photo" width="16" height="16" alt=""
<picture itemprop="image"> {{ if (eq .Site.BaseURL "http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/") -}}
<source srcset="{{ $favicon_svg.RelPermalink }}" type="image/svg+xml"> src="data:image/png;base64,{{ $favicon_base64 }}" srcset="{{ $favicon_bigpng.RelPermalink }} 2x"
{{- end -}} {{- else -}}
<img class="u-photo photo" src="data:image/png;base64,{{ $favicon_base64 }}" width="16" height="16" alt="" src="{{ $favicon_svg.RelPermalink }}"
srcset="{{ $favicon_bigpng.RelPermalink }} 2x">
{{- if (ne .Site.BaseURL "http://wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion/") -}}
</picture>
{{- end -}} {{- end -}}
>