mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-12-26 02:22:09 +00:00
6d066f8711
Allow specifying open graph images for individual pages. Change default site-wide open graph image alt-text to an empty string since the default image only has visual value, and is better off hidden from assistive technologies. Set an open graph image for two articles.
74 lines
4.7 KiB
HTML
74 lines
4.7 KiB
HTML
<head>
|
|
{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }}
|
|
<meta charset="utf-8">
|
|
<meta name="disabled-adaptations" content="watch"><meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
{{ if or (eq site.BaseURL site.Params.CanonicalBaseURL) (in site.BaseURL "wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion") -}}
|
|
<meta name="robots" content="index,follow,max-image-preview:large,max-snippet=-1">
|
|
{{ end -}}
|
|
<link href="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}" rel="canonical">
|
|
<link href="{{ .Site.Params.WebmentionEndpoint }}" rel="webmention">
|
|
{{ $webmanifest := resources.Get "/manifest.webmanifest" | resources.ExecuteAsTemplate "manifest.webmanifest" . | resources.Minify | resources.Fingerprint "md5" -}}
|
|
{{- printf `<link href="%s" rel="manifest">` $webmanifest.RelPermalink | safeHTML }}
|
|
<link rel="alternate" type="application/rss+xml" href="{{ site.BaseURL }}posts/index.xml" title="{{ $.Site.Title }}">
|
|
<title>{{ .Title }}{{ if and (lt (len .Title) 54) (ne $canonicalRelPermalink "/") }} - Seirdy{{ end }}</title>
|
|
{{ $description := .Site.Params.Description -}}
|
|
{{- if .Params.description -}}
|
|
{{- $description = .Params.Description -}}
|
|
{{- else if eq $canonicalRelPermalink "/posts.html" -}}
|
|
{{- $description = "All the posts on Seirdy's Home" -}}
|
|
{{- end -}}
|
|
<meta name="description" content="{{ $description }}">
|
|
<meta name="author" content="{{ .Site.Author.name }}">
|
|
<meta property="article:author" content="{{ .Site.Author.name }}">
|
|
{{ if gt .Date 0 -}}
|
|
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
|
|
{{ end -}}
|
|
{{ if lt .Date .Lastmod -}}
|
|
<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}">
|
|
{{- end -}}
|
|
<!--the Tor Browser's safest setting disables SVGs but still downloads them to avoid fingerprinting-->
|
|
{{ if not (in site.BaseURL ".onion") -}}
|
|
{{ $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 }}
|
|
{{- end }}
|
|
{{ $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 -}}
|
|
{{ $favicon := resources.Get "/favicon.png" -}}
|
|
{{ $favicon_base64 := $favicon.Content | base64Encode }}
|
|
{{ printf `<link rel="icon" sizes="32x32" href="data:image/png;base64,%s" type="image/png">` $favicon_base64 | safeHTML }}
|
|
<meta name="color-scheme" content="light dark">
|
|
<meta name="format-detection" content="telephone=no"><!-- Why does apple do this -->
|
|
<meta name="theme-color" content="#111" media="(prefers-color-scheme:dark)">
|
|
<meta name="theme-color" content="#fff" media="(prefers-color-scheme:light)">
|
|
<!-- inline CSS; remember to allow it with a hash in the CSP -->
|
|
{{- $resources := slice -}}
|
|
{{- $resources = $resources | append (resources.Get "/css/main.css") -}}
|
|
{{ $dark := .Site.Params.dark | default "auto" -}}
|
|
{{- if not (eq $dark "off") -}}
|
|
{{ $resources = $resources | append (resources.Get "css/dark.css" | resources.ExecuteAsTemplate "dark.css" .) -}}
|
|
{{- end -}}
|
|
{{ $resources = $resources | append (resources.Get "css/print.css" | resources.ExecuteAsTemplate "print.css" .) -}}
|
|
{{- $css := $resources | resources.Concat "css/style.css" | minify -}}
|
|
<style>{{ $css.Content | safeCSS }}</style>
|
|
<meta property="og:title" content="{{ .Title }}">
|
|
<meta property="og:site_name" content="{{ $.Site.Title }}">
|
|
{{- if not (or (ne "page" .Kind) (eq $canonicalRelPermalink "/bookmarks.html") (eq $canonicalRelPermalink "/posts.html")) }}
|
|
<meta property="og:type" content="article">
|
|
{{- end -}}
|
|
<!-- ANOTHER meta image?! When will it end? -->
|
|
{{- $og_image := resources.Get "/favicon512.png" | resources.Fingerprint "md5" -}}
|
|
{{- $og_image_alt := "" -}}<!--Default open graph image is purely decorative and visual, so it should be hidden from assistive technologies.-->
|
|
{{- with .Params.image -}}
|
|
{{- $og_image = resources.Get (printf "/p/%s" . ) | resources.Fingerprint "md5" -}}
|
|
{{- end -}}
|
|
{{- with .Params.image_alt -}}
|
|
{{- $og_image_alt = . -}}
|
|
{{- end }}
|
|
{{ printf `<meta property="og:image" content="%s">` $og_image.Permalink | safeHTML }}
|
|
<meta property="og:image:type" content="image/png">
|
|
<meta property="og:image:height" content="{{ $og_image.Height }}"><meta property="og:image:width" content="{{ $og_image.Width }}">
|
|
<meta property="og:image:alt" content="{{ $og_image_alt }}">
|
|
<meta property="og:url" content="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}">
|
|
<meta property="og:description" content="{{ $description }}">
|
|
{{ hugo.Generator | replaceRE " />" ">" | safeHTML}}
|
|
</head>
|