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

treat ALL images as assets (as they should have been all along...)

This commit is contained in:
2020-04-21 14:34:55 -04:00
parent 9a40dadfb2
commit 8ba0a887bc
34 changed files with 92 additions and 75 deletions

View File

@@ -1,32 +1,24 @@
{{/* Default image */}}
{{- $defaultImagePath := (path.Join "content" $.Site.Params.defaultImage) }}
{{ $.Scratch.Set "defaultImage_url" (replace $defaultImagePath "content/" "") }}
{{ with (imageConfig $defaultImagePath) }}
{{- $.Scratch.Set "defaultImage_width" .Width }}
{{- $.Scratch.Set "defaultImage_height" .Height }}
{{ end -}}
{{- $defaultImage := resources.Get $.Site.Params.defaultImage }}
{{- $.Scratch.Set "defaultImage_url" $defaultImage.Permalink }}
{{- $.Scratch.Set "defaultImage_width" $defaultImage.Width }}
{{- $.Scratch.Set "defaultImage_height" $defaultImage.Height }}
{{/* Article image (with fallback to default image */}}
{{/* Article image */}}
{{- with .Params.image }}
{{- $imagePath := (path.Join "content" $.File.Dir .) }}
{{- $.Scratch.Set "socialImage_url" (replace $imagePath "content/" "") }}
{{- with (imageConfig $imagePath) }}
{{- $.Scratch.Set "socialImage_width" .Width }}
{{- $.Scratch.Set "socialImage_height" .Height }}
{{- end }}
{{- $socialImage := $.Page.Resources.GetMatch . }}
{{- $.Scratch.Set "socialImage_url" $socialImage.Permalink }}
{{- $.Scratch.Set "socialImage_width" $socialImage.Width }}
{{- $.Scratch.Set "socialImage_height" $socialImage.Height }}
{{ else }}
{{- $.Scratch.Set "socialImage_url" (replace $defaultImagePath "content/" "") }}
{{- with (imageConfig $defaultImagePath) }}
{{- $.Scratch.Set "socialImage_width" .Width }}
{{- $.Scratch.Set "socialImage_height" .Height }}
{{- end }}
{{/* fallback to default image set above */}}
{{- $.Scratch.Set "socialImage_url" $defaultImage.Permalink }}
{{- $.Scratch.Set "socialImage_width" $defaultImage.Width }}
{{- $.Scratch.Set "socialImage_height" $defaultImage.Height }}
{{ end -}}
{{/* Site logo */}}
{{- $logoImagePath := (path.Join "content" "logo.png") }}
{{ $.Scratch.Set "logoImage_url" (replace $logoImagePath "content/" "") }}
{{ with (imageConfig $logoImagePath) }}
{{- $.Scratch.Set "logoImage_width" .Width }}
{{- $.Scratch.Set "logoImage_height" .Height }}
{{ end -}}
{{- $logoImage := resources.Get "img/logo.png" }}
{{- $.Scratch.Set "logoImage_url" $logoImage.Permalink }}
{{- $.Scratch.Set "logoImage_width" $logoImage.Width }}
{{- $.Scratch.Set "logoImage_height" $logoImage.Height }}

View File

@@ -1,10 +1,16 @@
<link rel="apple-touch-icon" href="{{ "apple-touch-icon.png" | absURL }}" sizes="180x180">
<link rel="mask-icon" href="{{ "safari-pinned-tab.svg" | absURL }}" color="#009cdf">
{{- $appleIcon := resources.Get "img/apple-touch-icon.png" }}
<link rel="apple-touch-icon" href="{{ $appleIcon.Permalink }}" sizes="{{ $appleIcon.Width }}x{{ $appleIcon.Height }}">
{{ range (split .pngSizes " ") -}}
<link rel="icon" href="{{ (printf "favicon-%v.png" .) | absURL }}" sizes="{{ . }}x{{ . }}">
{{ end -}}
{{- $safariIcon := resources.Get "img/safari-pinned-tab.svg" }}
<link rel="mask-icon" href="{{ $safariIcon.Permalink }}" color="#009cdf">
{{ $s := slice -}}
{{ range (split .icoSizes " ") }}{{ $s = $s | append (printf "%vx%v" . .) }}{{ end -}}
<link rel="shortcut icon" href="{{ "favicon.ico" | absURL }}" sizes="{{ delimit $s " " }}">
{{/* TODO: automate shrinking to given sizes based on one super big favicon */}}
{{- range (split .pngSizes " ") }}
{{- $faviconPng := resources.Get (printf "img/favicon-%v.png" .) }}
<link rel="icon" href="{{ $faviconPng.Permalink }}" sizes="{{ . }}x{{ . }}">
{{- end }}
{{- $s := slice }}
{{- range (split .icoSizes " ") }}{{ $s = $s | append (printf "%vx%v" . .) }}{{ end }}
{{- $faviconIco := resources.Get "img/favicon.ico" }}
<link rel="shortcut icon" href="{{ $faviconIco.Permalink }}" sizes="{{ delimit $s " " }}">

View File

@@ -1,5 +1,3 @@
<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="msapplication-TileColor" content="#0e6dc2">
<meta name="theme-color" content="#0e6dc2">

View File

@@ -4,7 +4,7 @@
{{/* Page-specific styles set via front matter, scoped via SCSS */}}
{{ with .Params.css }}
{{- $sass := printf "div#content { %s }" . }}
{{- $target := path.Join $.File.Dir "inline.scss" }}
{{- $target := path.Join $.File.Dir "css/inline.scss" }}
{{- $css := $sass | resources.FromString $target | resources.ToCSS | resources.PostCSS (dict "config" "postcss.config.js") -}}