1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-29 15:30:31 -04:00
jarv.is/layouts/partials/functions/prepare-meta.html
Jake Jarvis 3a3849e8ec
add a partial template that returns an asset's URL and hash from webpack's manifest
still a mess but slightly more modular. also added a real 404 page.
2021-09-03 11:16:27 -04:00

37 lines
1.5 KiB
HTML

{{/* Strip any markdown styling from page title for use in meta tags */}}
{{- with .Title -}}
{{- $.Scratch.Set "plainTitle" (. | markdownify | htmlUnescape | plainify) -}}
{{- end -}}
{{/* If this is a page/post, link View Source to specific file on GitHub; otherwise, just link to repo homepage */}}
{{- with .Site.Params.social.githubRepo -}}
{{- $githubURL := print "https://github.com/" . -}}
{{- if not $.IsPage -}}
{{- $.Scratch.Set "sourceURL" $githubURL -}}
{{- else -}}
{{- $.Scratch.Set "sourceURL" (print $githubURL "/blob/main/content/" $.File.Path) -}}
{{- end -}}
{{- end -}}
{{/* Chooses and initializes various images for use by JSON schema & open graph tags */}}
{{/* Author image (default) */}}
{{- with partial "functions/webpack" (dict "context" . "src" .Site.Author.image) -}}
{{- $.Scratch.Set "authorImage" (dict "Permalink" .src "Width" 1200 "Height" 1200 "MediaType" "image/jpeg") -}}
{{- end -}}
{{/* Page image (via frontmatter) */}}
{{- 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 */}}
{{- with partial "functions/webpack" (dict "context" . "src" .Site.Params.image) -}}
{{- $.Scratch.Set "logoImage" (dict "Permalink" .src "Width" 2048 "Height" 2048 "MediaType" "image/png") -}}
{{- end -}}