1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-27 05:18:28 -04:00

detect image properties for meta tags without hacky mounts

still a little hacky re: permalinks though....
This commit is contained in:
Jake Jarvis 2019-12-21 11:06:46 -05:00
parent 47016b1109
commit 6ae5aeb3e3
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
8 changed files with 17 additions and 31 deletions

View File

@ -107,17 +107,3 @@ disableAliases = true
enableDNT = true
[privacy.youtube]
privacyEnhanced = true
# TODO: find better way than double-mounting content as weird hack to allow
# access to image resources from templates.
# https://gohugo.io/hugo-modules/configuration/#module-config-mounts
[module]
[[module.mounts]]
source = "content"
target = "assets/content"
[[module.mounts]]
source = "assets"
target = "assets"
[[module.mounts]]
source = "content"
target = "content"

View File

@ -1,6 +1,6 @@
---
title: "Jake Jarvis Front-End Web Developer in Boston, MA"
date: 2019-12-17 11:23:21-0400
date: 2019-12-20 23:47:30-0400
type: home
---

Binary file not shown.

View File

@ -1,8 +1,8 @@
{{- $image := "" }}
{{- $imagePath := "" }}
{{- with .Params.image }}
{{- $image = resources.Get (printf "%s%s%s%s" "content" ($.OutputFormats.Get "html").RelPermalink "images/" .) }}
{{- $imagePath = (path.Join "content" $.File.Dir "images/" .) }}
{{- else }}
{{- $image = resources.Get (printf "%s%s" "content" $.Site.Params.defaultimage) }}
{{- $imagePath = (path.Join "content" $.Site.Params.defaultimage) }}
{{- end }}
<meta property="og:title" content="{{ .Title }}">
@ -12,8 +12,8 @@
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:description" content="{{ if .Description }}{{ .Description }}{{ else }}{{ .Site.Params.description }}{{ end }}">
{{- with $image }}
<meta property="og:image" content="{{ replace .Permalink "/content/" "/" }}">
{{- 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 }}">

View File

@ -1,6 +1,6 @@
{{- $image := "" }}
{{- $imagePath := "" }}
{{- with .Params.image }}
{{- $image = resources.Get (printf "%s%s%s%s" "content" ($.OutputFormats.Get "html").RelPermalink "images/" .) }}
{{- $imagePath = (path.Join "content" $.File.Dir "images/" .) }}
{{- end }}
<script type="application/ld+json">
@ -29,10 +29,10 @@
"width": "2048",
"height": "2048"
}
}{{ with $image }},
}{{ with (imageConfig $imagePath) }},
"image": {
"@type": "ImageObject",
"url": {{ replace .Permalink "/content/" "/" }},
"url": {{ replace $imagePath "content/" $.Site.BaseURL }},
"width": "{{ .Width }}",
"height": "{{ .Height }}"
}

View File

@ -1,9 +1,9 @@
{{- with .Site.Author -}}
{{- $image := "" }}
{{- $imagePath := "" }}
{{- with $.Site.Params.defaultimage }}
{{- $image = resources.Get (printf "%s%s" "content" .) }}
{{- end -}}
{{- $imagePath = (path.Join "content" .) }}
{{- end }}
<script type="application/ld+json">
{
@ -14,10 +14,10 @@
"url": {{ $.Site.BaseURL }},
"description": {{ $.Site.Params.description }},
{{ with .jobtitle }}"jobTitle": {{ . }},{{ end }}
{{- with $image }}
{{- with (imageConfig $imagePath) }}
"image": {
"@type": "ImageObject",
"url": {{ replace .Permalink "/content/" "/" }},
"url": {{ replace $imagePath "content/" $.Site.BaseURL }},
"width": "{{ .Width }}",
"height": "{{ .Height }}"
},

View File

@ -3,7 +3,7 @@
publish = "public"
[build.environment]
NODE_VERSION = "12.13.1"
NODE_VERSION = "12.14.0"
YARN_VERSION = "1.21.1"
YARN_FLAGS = "--no-ignore-optional --frozen-lockfile"

View File

@ -23,7 +23,7 @@
"optimize": "run-p optimize:**",
"optimize:html": "html-minifier --html5 --collapse-whitespace --preserve-line-breaks --minify-css --file-ext html --input-dir public --output-dir public **/*.html",
"optimize:css": "cleancss -O0 --format 'keep-breaks' -o public/style.css public/style.css",
"optimize:img": "rimraf public/content/; find public/ -type d | xargs -n1 -P8 -I{} imagemin {}/* --plugin=jpegoptim --plugin.jpegoptim.progressive --plugin=pngquant --plugin.pngquant.speed=3 --plugin.pngquant.strip --plugin=optipng --plugin.optipng.optimizationLevel=3 --plugin=svgo --plugin=gifsicle --out-dir={}",
"optimize:img": "find public/ -type d | xargs -n1 -P8 -I{} imagemin {}/* --plugin=jpegoptim --plugin.jpegoptim.progressive --plugin=pngquant --plugin.pngquant.speed=3 --plugin.pngquant.strip --plugin=optipng --plugin.optipng.optimizationLevel=3 --plugin=svgo --plugin=gifsicle --out-dir={}",
"lint": "run-p lint:**",
"lint:markdown": "markdownlint content/notes/**/*.md",
"lint:sass": "stylelint assets/sass/**/* --syntax scss",