mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-27 12:36:20 -04:00
playing with Scratch to re-use image logic -- still messy but it's progress
This commit is contained in:
parent
762a82b3cb
commit
027725faf1
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
@ -4,6 +4,7 @@
|
||||
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Site.Params.description }}{{ end }}">
|
||||
{{ with .Site.Author.name }}<meta name="author" content="{{ . }}">{{ end }}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
{{ partial "social-images" . }}
|
||||
{{ partial "open-graph" . }}
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
||||
|
@ -1,10 +1,3 @@
|
||||
{{- $imagePath := "" }}
|
||||
{{- with .Params.image }}
|
||||
{{- $imagePath = (path.Join "content" $.File.Dir "images/" .) }}
|
||||
{{- else }}
|
||||
{{- $imagePath = (path.Join "content" $.Site.Params.defaultimage) }}
|
||||
{{- end }}
|
||||
|
||||
<meta property="og:title" content="{{ .Title }}">
|
||||
<meta property="og:site_name" content="{{ .Site.Title }}">
|
||||
<meta property="og:type" content="{{ if and .IsPage (eq .Type "notes") }}article{{ else }}website{{ end }}">
|
||||
@ -12,12 +5,10 @@
|
||||
<meta property="og:url" content="{{ .Permalink }}">
|
||||
<meta property="og:description" content="{{ if .Description }}{{ .Description }}{{ else }}{{ .Site.Params.description }}{{ end }}">
|
||||
|
||||
{{- with (imageConfig $imagePath) }}
|
||||
<meta property="og:image" content="{{ replace $imagePath "content/" $.Site.BaseURL }}">
|
||||
<meta property="og:image:width" content="{{ .Width }}">
|
||||
<meta property="og:image:height" content="{{ .Height }}">
|
||||
<meta property="og:image:alt" content="{{ $.Title }}">
|
||||
{{- end }}
|
||||
<meta property="og:image" content="{{ .Scratch.Get "socialImage_url" }}">
|
||||
<meta property="og:image:width" content="{{ .Scratch.Get "socialImage_width" }}">
|
||||
<meta property="og:image:height" content="{{ .Scratch.Get "socialImage_height" }}">
|
||||
<meta property="og:image:alt" content="{{ .Title }}">
|
||||
|
||||
{{- if and .IsPage (eq .Type "notes") }}
|
||||
{{- if not .PublishDate.IsZero }}
|
||||
|
@ -1,8 +1,3 @@
|
||||
{{- $imagePath := "" }}
|
||||
{{- with .Params.image }}
|
||||
{{- $imagePath = (path.Join "content" $.File.Dir "images/" .) }}
|
||||
{{- end }}
|
||||
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "http://schema.org",
|
||||
@ -25,17 +20,16 @@
|
||||
"url": {{ .Site.BaseURL }},
|
||||
"logo": {
|
||||
"@type": "ImageObject",
|
||||
"url": {{ "logo.png" | absURL }},
|
||||
"width": "2048",
|
||||
"height": "2048"
|
||||
"url": {{ .Scratch.Get "logoImage_url" }},
|
||||
"width": "{{ .Scratch.Get "logoImage_width" }}",
|
||||
"height": "{{ .Scratch.Get "logoImage_height" }}"
|
||||
}
|
||||
}{{ with (imageConfig $imagePath) }},
|
||||
},
|
||||
"image": {
|
||||
"@type": "ImageObject",
|
||||
"url": {{ replace $imagePath "content/" $.Site.BaseURL }},
|
||||
"width": "{{ .Width }}",
|
||||
"height": "{{ .Height }}"
|
||||
"url": {{ .Scratch.Get "socialImage_url" }},
|
||||
"width": "{{ .Scratch.Get "socialImage_width" }}",
|
||||
"height": "{{ .Scratch.Get "socialImage_height" }}"
|
||||
}
|
||||
{{- end }}
|
||||
}
|
||||
</script>
|
||||
|
@ -1,10 +1,4 @@
|
||||
{{- with .Site.Author -}}
|
||||
|
||||
{{- $imagePath := "" }}
|
||||
{{- with $.Site.Params.defaultimage }}
|
||||
{{- $imagePath = (path.Join "content" .) }}
|
||||
{{- end }}
|
||||
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "http://schema.org",
|
||||
@ -14,14 +8,12 @@
|
||||
"url": {{ $.Site.BaseURL }},
|
||||
"description": {{ $.Site.Params.description }},
|
||||
{{ with .jobtitle }}"jobTitle": {{ . }},{{ end }}
|
||||
{{- with (imageConfig $imagePath) }}
|
||||
"image": {
|
||||
"@type": "ImageObject",
|
||||
"url": {{ replace $imagePath "content/" $.Site.BaseURL }},
|
||||
"width": "{{ .Width }}",
|
||||
"height": "{{ .Height }}"
|
||||
"url": {{ $.Scratch.Get "defaultImage_url" }},
|
||||
"width": "{{ $.Scratch.Get "defaultImage_width" }}",
|
||||
"height": "{{ $.Scratch.Get "defaultImage_height" }}"
|
||||
},
|
||||
{{- end }}
|
||||
"sameAs": [
|
||||
{{ $.Site.BaseURL }},
|
||||
{{ with .github }}{{ printf "%s%s" "https://github.com/" . }},{{ end }}
|
||||
|
32
layouts/partials/social-images.html
Normal file
32
layouts/partials/social-images.html
Normal file
@ -0,0 +1,32 @@
|
||||
{{- /* Default image */ -}}
|
||||
{{- $defaultImagePath := (path.Join "content" $.Site.Params.defaultimage) }}
|
||||
{{- $.Scratch.Set "defaultImage_url" (replace $defaultImagePath "content/" $.Site.BaseURL) }}
|
||||
{{- with (imageConfig $defaultImagePath) }}
|
||||
{{- $.Scratch.Set "defaultImage_width" .Width }}
|
||||
{{- $.Scratch.Set "defaultImage_height" .Height }}
|
||||
{{- end }}
|
||||
|
||||
{{- /* Article image (with fallback to default image */ -}}
|
||||
{{- with .Params.image }}
|
||||
{{- $imagePath := (path.Join "content" $.File.Dir "images/" .) }}
|
||||
|
||||
{{- $.Scratch.Set "socialImage_url" (replace $imagePath "content/" $.Site.BaseURL) }}
|
||||
{{- with (imageConfig $imagePath) }}
|
||||
{{- $.Scratch.Set "socialImage_width" .Width }}
|
||||
{{- $.Scratch.Set "socialImage_height" .Height }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $.Scratch.Set "socialImage_url" (replace $defaultImagePath "content/" $.Site.BaseURL) }}
|
||||
{{- with (imageConfig $defaultImagePath) }}
|
||||
{{- $.Scratch.Set "socialImage_width" .Width }}
|
||||
{{- $.Scratch.Set "socialImage_height" .Height }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- /* Site logo */ -}}
|
||||
{{- $logoImagePath := (path.Join "content" "logo.png") }}
|
||||
{{- $.Scratch.Set "logoImage_url" (replace $logoImagePath "content/" $.Site.BaseURL) }}
|
||||
{{- with (imageConfig $logoImagePath) }}
|
||||
{{- $.Scratch.Set "logoImage_width" .Width }}
|
||||
{{- $.Scratch.Set "logoImage_height" .Height }}
|
||||
{{- end }}
|
Loading…
x
Reference in New Issue
Block a user