1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-19 23:35:31 -04:00

clean up a bunch of layouts, especially social-images function

also made even more config.toml parameters optional, will help when finally releasing theme
This commit is contained in:
2020-06-25 10:35:59 -04:00
parent 0a48ce296f
commit f3198e0235
31 changed files with 167 additions and 162 deletions

View File

@@ -1,15 +1,15 @@
{{ $svg := resources.Get .src -}}
{{ $html := $svg.Content -}}
{{- $svg := resources.Get .src -}}
{{- $html := $svg.Content -}}
{{/* remove unneeded tags/attributes when SVG is inlined versus a .svg file */}}
{{ $html = replaceRE "<\\?xml.+\\?>" "" $html -}}
{{ $html = replaceRE " version=\"(.*?)\"" "" $html -}}
{{ $html = replaceRE " xmlns=\"(.*?)\"" "" $html -}}
{{- $html = replaceRE "<\\?xml.+\\?>" "" $html -}}
{{- $html = replaceRE " version=\"(.*?)\"" "" $html -}}
{{- $html = replaceRE " xmlns=\"(.*?)\"" "" $html -}}
{{ $wxh := printf "<svg width=\"%d\" height=\"%d\"" .width .height }}
{{- $wxh := printf "<svg width=\"%d\" height=\"%d\" " .width .height }}
{{ $html = replace $html "<svg" $wxh -}}
{{- $html = replace $html "<svg " $wxh -}}
{{/* bit of a hack: calling .Permalink so that the SVG file is published too */}}
{{ printf "<!-- auto-inlined from: %s -->" $svg.Permalink | safeHTML }}
{{ $html | safeHTML -}}
{{/* bit of a hack: calling .Permalink so that the SVG file is published too, comment will be removed when minified */}}
{{- printf "<!-- auto-inlined from: %s -->" $svg.Permalink | safeHTML }}
{{- $html | safeHTML -}}

View File

@@ -3,7 +3,7 @@
{{ $original := .Page.Resources.GetMatch (.Get "src") }}
{{ .Scratch.Set "image" $original }}
{{ $setWidth := .Site.Params.pageMaxWidth }}
{{ $setWidth := .Site.Params.maxWidth }}
{{ if .Get "width" }}
{{ $setWidth = (int (.Get "width")) }}
@@ -22,4 +22,4 @@
{{ $displayWidth := $setWidth }}
{{ $displayHeight := (math.Ceil (mul $origRatio $setWidth)) }}
{{ return (dict "Permalink" $image.Permalink "Width" $displayWidth "Height" $displayHeight) }}
{{ return (dict "Permalink" $image.Permalink "Width" $displayWidth "Height" $displayHeight "MediaType" $image.MediaType) }}

View File

@@ -1,28 +1,27 @@
{{/* Default image */}}
{{- $defaultImage := resources.Get $.Site.Params.defaultImage }}
{{- $.Scratch.Set "defaultImage_url" $defaultImage.Permalink }}
{{- $.Scratch.Set "defaultImage_width" $defaultImage.Width }}
{{- $.Scratch.Set "defaultImage_height" $defaultImage.Height }}
{{- $.Scratch.Set "defaultImage_type" $defaultImage.MediaType }}
{{/* Chooses and initializes various images for use by JSON schema & open graph tags */}}
{{/* Author image (default) */}}
{{- with .Site.Author.image -}}
{{- with resources.Get . -}}
{{- $.Scratch.Set "authorImage" . -}}
{{- end -}}
{{- end -}}
{{/* Article image */}}
{{- with .Params.image }}
{{- $socialImage := $.Page.Resources.GetMatch . }}
{{- $.Scratch.Set "socialImage_url" $socialImage.Permalink }}
{{- $.Scratch.Set "socialImage_width" $socialImage.Width }}
{{- $.Scratch.Set "socialImage_height" $socialImage.Height }}
{{- $.Scratch.Set "socialImage_type" $socialImage.MediaType }}
{{ else }}
{{/* fallback to default image set above */}}
{{- $.Scratch.Set "socialImage_url" $defaultImage.Permalink }}
{{- $.Scratch.Set "socialImage_width" $defaultImage.Width }}
{{- $.Scratch.Set "socialImage_height" $defaultImage.Height }}
{{- $.Scratch.Set "socialImage_type" $defaultImage.MediaType }}
{{ end -}}
{{- with .Params.image -}}
{{- with $.Page.Resources.GetMatch . -}}
{{- $.Scratch.Set "pageImage" . -}}
{{- end -}}
{{- else -}}
{{/* Fallback to author image set above */}}
{{- with $.Scratch.Get "authorImage" -}}
{{- $.Scratch.Set "pageImage" . -}}
{{- end -}}
{{- end -}}
{{/* Site logo */}}
{{- $logoImage := resources.Get "img/logo.png" }}
{{- $.Scratch.Set "logoImage_url" $logoImage.Permalink }}
{{- $.Scratch.Set "logoImage_width" $logoImage.Width }}
{{- $.Scratch.Set "logoImage_height" $logoImage.Height }}
{{- $.Scratch.Set "logoImage_type" $logoImage.MediaType }}
{{- with .Site.Params.image -}}
{{- with resources.Get . -}}
{{- $.Scratch.Set "logoImage" . -}}
{{- end -}}
{{- end -}}