1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-26 14:28:25 -04:00

50 lines
1.8 KiB
HTML

{{- partial "scripts/_bundle" . -}}
{{/* 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 .Site.Author.image -}}
{{- with resources.Get . -}}
{{- $.Scratch.Set "authorImage" . -}}
{{- end -}}
{{- 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 .Site.Params.image -}}
{{- with resources.Get . -}}
{{- $.Scratch.Set "logoImage" . -}}
{{- end -}}
{{- end -}}
{{/* Page-specific styles set via front matter, piped through PostCSS and inlined */}}
{{- with .Params.css -}}
{{/* NOTE: This file doesn't end up getting published (which is good) */}}
{{- $target := path.Join $.File.Dir "css/inline.scss" -}}
{{- $css := . | resources.FromString $target | resources.ExecuteAsTemplate $target . | resources.ToCSS (dict "targetPath" $target) | resources.PostCSS (dict "config" "postcss.config.js") -}}
{{- $.Scratch.Set "pageCss" $css.Content -}}
{{- end -}}