1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-19 15:45:33 -04:00

very, VERY hacky way to determine image width/height for meta tags

This commit is contained in:
2019-11-23 09:21:06 -05:00
parent 1ea90613c9
commit 673ddbb27b
10 changed files with 139 additions and 104 deletions

View File

@@ -21,7 +21,7 @@
<link rel="icon" href="{{ "favicon-48.png" | absURL }}" sizes="48x48">
<link rel="icon" href="{{ "favicon-32.png" | absURL }}" sizes="32x32">
<link rel="icon" href="{{ "favicon-16.png" | absURL }}" sizes="16x16">
<link rel="shortcut icon" href="{{ "favicon.ico" | absURL }}">
<link rel="shortcut icon" href="{{ "favicon.ico" | absURL }}" sizes="16x16 32x32 48x48">
<link rel="canonical" href="{{ .Permalink }}">
<link rel="alternate" type="application/rss+xml" href="{{ "index.xml" | absURL }}" title="{{ .Site.Title }} (RSS)">
<link rel="author" href="{{ "humans.txt" | absURL }}">

View File

@@ -1,10 +1,24 @@
{{- $imagePath := "null" -}}
{{- if .Params.image }}
{{ $imagePath = (printf "%s%s%s%s" "content" (.OutputFormats.Get "html").RelPermalink "images/" .Params.image ) }}
{{- else }}
{{ $imagePath = "content/me_large.jpg" }}
{{- end -}}
{{- $imageResource := resources.Get $imagePath }}
{{- .Scratch.Set "image" $imageResource }}
{{- $image := .Scratch.Get "image" -}}
<meta property="og:title" content="{{ .Title }}">
<meta property="og:site_name" content="{{ .Site.Title }}">
<meta property="og:type" content="{{ if .IsHome }}website{{ else }}article{{ end }}">
<meta property="og:locale" content="en_US">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:description" content="{{ if .Description }}{{ .Description }}{{ else }}{{ .Site.Params.description }}{{ end }}">
<meta property="og:image" content="{{ if .Params.image }}{{ (printf "%s%s%s" (.OutputFormats.Get "html").Permalink "images/" .Params.image ) }}{{ else }}{{ "me_lg.jpg" | absURL }}{{ end }}">
<meta property="og:image" content="{{ if .Params.image }}{{ (printf "%s%s%s" (.OutputFormats.Get "html").Permalink "images/" .Params.image ) }}{{ else }}{{ "me_large.jpg" | absURL }}{{ end }}">
<meta property="og:image:width" content="{{ $image.Width }}">
<meta property="og:image:height" content="{{ $image.Height }}">
{{- if .IsPage }}
{{- if not .PublishDate.IsZero }}
<meta property="article:published_time" content="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTMLAttr }}">

View File

@@ -1,3 +1,15 @@
{{- $imagePath := "null" -}}
{{- if .Params.image }}
{{ $imagePath = (printf "%s%s%s%s" "content" (.OutputFormats.Get "html").RelPermalink "images/" .Params.image ) }}
{{- else }}
{{ $imagePath = "content/me_large.jpg" }}
{{- end -}}
{{- $imageResource := resources.Get $imagePath }}
{{- .Scratch.Set "image" $imageResource }}
{{- $image := .Scratch.Get "image" -}}
<script type="application/ld+json">
{
"@context": "http://schema.org",
@@ -16,9 +28,9 @@
"url": {{ .Site.BaseURL }},
"image": {
"@type": "ImageObject",
"url": {{ "me_lg.jpg" | absURL }},
"width": 920,
"height": 920
"url": {{ "me_large.jpg" | absURL }},
"width": "1000",
"height": "1000"
}
},
"publisher": {
@@ -27,14 +39,16 @@
"url": {{ .Site.BaseURL }},
"logo": {
"@type": "ImageObject",
"url": {{ "favicon-512.png" | absURL }},
"width": 512,
"height": 512
"url": {{ "logo.png" | absURL }},
"width": "2048",
"height": "2048"
}
},
"image": {
"@type": "ImageObject",
"url": {{ if .Params.image }}{{ (printf "%s%s%s" (.OutputFormats.Get "html").Permalink "images/" .Params.image ) }}{{ else }}{{ "me_lg.jpg" | absURL }}{{ end }}
"url": {{ if .Params.image }}{{ (printf "%s%s%s" (.OutputFormats.Get "html").Permalink "images/" .Params.image ) }}{{ else }}{{ "me_large.jpg" | absURL }}{{ end }},
"width": "{{ $image.Width }}",
"height": "{{ $image.Height }}"
}
}
</script>

View File

@@ -8,9 +8,9 @@
"jobTitle": {{ .Site.Author.jobtitle }},
"image": {
"@type": "ImageObject",
"url": {{ "me_lg.jpg" | absURL }},
"width": 920,
"height": 920
"url": {{ "me_large.jpg" | absURL }},
"width": "1000",
"height": "1000"
},
"sameAs": [
{{ .Site.BaseURL }},