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

make optimize-image more function-like

....instead of relying on $.Scratch
This commit is contained in:
2020-01-15 10:30:01 -05:00
parent 827ffd20e3
commit f51e912632
7 changed files with 48 additions and 46 deletions

View File

@@ -5,4 +5,6 @@
<link rel="icon" href="{{ (printf "favicon-%v.png" .) | absURL }}" sizes="{{ . }}x{{ . }}">
{{ end -}}
<link rel="shortcut icon" href="{{ "favicon.ico" | absURL }}" sizes="{{ .ico_sizes }}">
{{ $s := slice -}}
{{ range (split .ico_sizes " ") }}{{ $s = $s | append (printf "%vx%v" . .) }}{{ end -}}
<link rel="shortcut icon" href="{{ "favicon.ico" | absURL }}" sizes="{{ delimit $s " " }}">

View File

@@ -1,22 +1,22 @@
{{ partial "head/meta" . }}
{{ partial "head/social-images" . }}
{{ partial "head/open-graph" . }}
{{ partial "head/meta" . -}}
{{ partial "head/social-images" . -}}
{{ partial "head/open-graph" . -}}
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="apple-mobile-web-app-title" content="{{ .Site.Title }}">
<meta name="theme-color" content="#0e6dc2">
{{ partialCached "head/preload" . }}
{{ partialCached "head/styles" . }}
{{ partialCached "head/favicons" (dict "png_sizes" "192 48 32 16" "ico_sizes" "16x16 32x32 48x48") }}
{{ partialCached "head/preload" . -}}
{{ partialCached "head/styles" . -}}
{{ partialCached "head/favicons" (dict "png_sizes" "192 48 32 16" "ico_sizes" "16 32 48") -}}
<link rel="canonical" href="{{ .Permalink }}">
<link rel="alternate" type="application/rss+xml" href="{{ "feed.xml" | absURL }}" title="{{ .Site.Title }} (RSS)">
<link rel="author" href="{{ "humans.txt" | absURL }}">
{{ if and .IsPage (eq .Type "notes") }}
{{ with .OutputFormats.Get "amp" }}
{{- with .OutputFormats.Get "amp" -}}
<link rel="amphtml" href="{{ .Permalink }}">
{{ end }}
{{- end }}
{{ partial "head/schema-person" . }}
{{ partial "head/schema-article" . }}
{{ else }}
{{ partial "head/schema-person" . }}
{{ end }}
{{ end -}}

View File

@@ -1,12 +1,12 @@
{{- /* Default image */ -}}
{{/* Default image */}}
{{- $defaultImagePath := (path.Join "content" $.Site.Params.defaultimage) }}
{{- $.Scratch.Set "defaultImage_url" (replace $defaultImagePath "content/" $.Site.BaseURL) }}
{{- with (imageConfig $defaultImagePath) }}
{{ $.Scratch.Set "defaultImage_url" (replace $defaultImagePath "content/" $.Site.BaseURL) }}
{{ with (imageConfig $defaultImagePath) }}
{{- $.Scratch.Set "defaultImage_width" .Width }}
{{- $.Scratch.Set "defaultImage_height" .Height }}
{{- end }}
{{ end -}}
{{- /* Article image (with fallback to default image */ -}}
{{/* Article image (with fallback to default image */}}
{{- with .Params.image }}
{{- $imagePath := (path.Join "content" $.File.Dir "images/" .) }}
@@ -15,18 +15,18 @@
{{- $.Scratch.Set "socialImage_width" .Width }}
{{- $.Scratch.Set "socialImage_height" .Height }}
{{- end }}
{{- else }}
{{ 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 }}
{{ end -}}
{{- /* Site logo */ -}}
{{/* Site logo */}}
{{- $logoImagePath := (path.Join "content" "logo.png") }}
{{- $.Scratch.Set "logoImage_url" (replace $logoImagePath "content/" $.Site.BaseURL) }}
{{- with (imageConfig $logoImagePath) }}
{{ $.Scratch.Set "logoImage_url" (replace $logoImagePath "content/" $.Site.BaseURL) }}
{{ with (imageConfig $logoImagePath) }}
{{- $.Scratch.Set "logoImage_width" .Width }}
{{- $.Scratch.Set "logoImage_height" .Height }}
{{- end }}
{{ end -}}