mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-07-19 12:55:31 -04:00
clean up a bunch of layouts, especially social-images function
also made even more config.toml parameters optional, will help when finally releasing theme
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
{{ $svg := resources.Get .src -}}
|
||||
{{ $html := $svg.Content -}}
|
||||
{{- $svg := resources.Get .src -}}
|
||||
{{- $html := $svg.Content -}}
|
||||
|
||||
{{/* remove unneeded tags/attributes when SVG is inlined versus a .svg file */}}
|
||||
{{ $html = replaceRE "<\\?xml.+\\?>" "" $html -}}
|
||||
{{ $html = replaceRE " version=\"(.*?)\"" "" $html -}}
|
||||
{{ $html = replaceRE " xmlns=\"(.*?)\"" "" $html -}}
|
||||
{{- $html = replaceRE "<\\?xml.+\\?>" "" $html -}}
|
||||
{{- $html = replaceRE " version=\"(.*?)\"" "" $html -}}
|
||||
{{- $html = replaceRE " xmlns=\"(.*?)\"" "" $html -}}
|
||||
|
||||
{{ $wxh := printf "<svg width=\"%d\" height=\"%d\"" .width .height }}
|
||||
{{- $wxh := printf "<svg width=\"%d\" height=\"%d\" " .width .height }}
|
||||
|
||||
{{ $html = replace $html "<svg" $wxh -}}
|
||||
{{- $html = replace $html "<svg " $wxh -}}
|
||||
|
||||
{{/* bit of a hack: calling .Permalink so that the SVG file is published too */}}
|
||||
{{ printf "<!-- auto-inlined from: %s -->" $svg.Permalink | safeHTML }}
|
||||
{{ $html | safeHTML -}}
|
||||
{{/* bit of a hack: calling .Permalink so that the SVG file is published too, comment will be removed when minified */}}
|
||||
{{- printf "<!-- auto-inlined from: %s -->" $svg.Permalink | safeHTML }}
|
||||
{{- $html | safeHTML -}}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
{{ $original := .Page.Resources.GetMatch (.Get "src") }}
|
||||
{{ .Scratch.Set "image" $original }}
|
||||
|
||||
{{ $setWidth := .Site.Params.pageMaxWidth }}
|
||||
{{ $setWidth := .Site.Params.maxWidth }}
|
||||
|
||||
{{ if .Get "width" }}
|
||||
{{ $setWidth = (int (.Get "width")) }}
|
||||
@@ -22,4 +22,4 @@
|
||||
{{ $displayWidth := $setWidth }}
|
||||
{{ $displayHeight := (math.Ceil (mul $origRatio $setWidth)) }}
|
||||
|
||||
{{ return (dict "Permalink" $image.Permalink "Width" $displayWidth "Height" $displayHeight) }}
|
||||
{{ return (dict "Permalink" $image.Permalink "Width" $displayWidth "Height" $displayHeight "MediaType" $image.MediaType) }}
|
||||
|
@@ -1,28 +1,27 @@
|
||||
{{/* Default image */}}
|
||||
{{- $defaultImage := resources.Get $.Site.Params.defaultImage }}
|
||||
{{- $.Scratch.Set "defaultImage_url" $defaultImage.Permalink }}
|
||||
{{- $.Scratch.Set "defaultImage_width" $defaultImage.Width }}
|
||||
{{- $.Scratch.Set "defaultImage_height" $defaultImage.Height }}
|
||||
{{- $.Scratch.Set "defaultImage_type" $defaultImage.MediaType }}
|
||||
{{/* 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 -}}
|
||||
|
||||
{{/* Article image */}}
|
||||
{{- with .Params.image }}
|
||||
{{- $socialImage := $.Page.Resources.GetMatch . }}
|
||||
{{- $.Scratch.Set "socialImage_url" $socialImage.Permalink }}
|
||||
{{- $.Scratch.Set "socialImage_width" $socialImage.Width }}
|
||||
{{- $.Scratch.Set "socialImage_height" $socialImage.Height }}
|
||||
{{- $.Scratch.Set "socialImage_type" $socialImage.MediaType }}
|
||||
{{ else }}
|
||||
{{/* fallback to default image set above */}}
|
||||
{{- $.Scratch.Set "socialImage_url" $defaultImage.Permalink }}
|
||||
{{- $.Scratch.Set "socialImage_width" $defaultImage.Width }}
|
||||
{{- $.Scratch.Set "socialImage_height" $defaultImage.Height }}
|
||||
{{- $.Scratch.Set "socialImage_type" $defaultImage.MediaType }}
|
||||
{{ end -}}
|
||||
{{- 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 */}}
|
||||
{{- $logoImage := resources.Get "img/logo.png" }}
|
||||
{{- $.Scratch.Set "logoImage_url" $logoImage.Permalink }}
|
||||
{{- $.Scratch.Set "logoImage_width" $logoImage.Width }}
|
||||
{{- $.Scratch.Set "logoImage_height" $logoImage.Height }}
|
||||
{{- $.Scratch.Set "logoImage_type" $logoImage.MediaType }}
|
||||
{{- with .Site.Params.image -}}
|
||||
{{- with resources.Get . -}}
|
||||
{{- $.Scratch.Set "logoImage" . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
@@ -2,13 +2,13 @@
|
||||
{{ partial "functions/social-images" . -}}
|
||||
{{ partial "head/open-graph" . -}}
|
||||
{{ partialCached "head/mobile" . -}}
|
||||
{{ partial "head/preload" . -}}
|
||||
{{ partialCached "head/preload" . -}}
|
||||
{{ partial "head/styles" . -}}
|
||||
{{ partialCached "head/favicons" (dict "pngSizes" "192 48 32 16" "icoSizes" "16 32 48") -}}
|
||||
{{ partialCached "head/feeds" . -}}
|
||||
{{ partialCached "head/webmention" . -}}
|
||||
{{ partial "head/canonical" . -}}
|
||||
{{ partial "head/schema" . -}}
|
||||
{{ if eq hugo.Environment "production" }}
|
||||
{{ partial "scripts/simple_analytics_events" . -}}
|
||||
{{ end }}
|
||||
{{ if eq hugo.Environment "production" -}}
|
||||
{{ partialCached "scripts/simple_analytics_events" . -}}
|
||||
{{ end -}}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<link rel="canonical" href="{{ .Permalink }}">
|
||||
{{ if and .IsPage (eq .Type .Site.Params.mainSection) }}
|
||||
{{- with .OutputFormats.Get "amp" -}}
|
||||
<link rel="amphtml" href="{{ .Permalink }}">
|
||||
<link rel="amphtml" href="{{ .Permalink }}">
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
<link rel="author" href="{{ "humans.txt" | absURL }}">
|
||||
|
@@ -7,10 +7,10 @@
|
||||
{{- range (split .pngSizes " ") }}
|
||||
{{- $faviconPng := resources.Get (printf "img/favicon-%v.png" .) }}
|
||||
<link rel="icon" href="{{ $faviconPng.Permalink }}" sizes="{{ . }}x{{ . }}">
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{- $s := slice }}
|
||||
{{- range (split .icoSizes " ") }}{{ $s = $s | append (printf "%vx%v" . .) }}{{ 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 " " }}">
|
||||
|
||||
|
@@ -5,11 +5,13 @@
|
||||
<meta property="og:url" content="{{ .Permalink }}">
|
||||
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Site.Params.description }}{{ end }}">
|
||||
|
||||
<meta property="og:image" content="{{ .Scratch.Get "socialImage_url" | absURL }}">
|
||||
<meta property="og:image:type" content="{{ .Scratch.Get "socialImage_type" }}">
|
||||
<meta property="og:image:width" content="{{ .Scratch.Get "socialImage_width" }}">
|
||||
<meta property="og:image:height" content="{{ .Scratch.Get "socialImage_height" }}">
|
||||
<meta property="og:image:alt" content="{{ .Title }}">
|
||||
{{- with .Scratch.Get "pageImage" }}
|
||||
<meta property="og:image" content="{{ .Permalink }}">
|
||||
<meta property="og:image:type" content="{{ .MediaType }}">
|
||||
<meta property="og:image:width" content="{{ .Width }}">
|
||||
<meta property="og:image:height" content="{{ .Height }}">
|
||||
<meta property="og:image:alt" content="{{ $.Title }}">
|
||||
{{ end -}}
|
||||
|
||||
{{- if and .IsPage (eq .Type .Site.Params.mainSection) }}
|
||||
{{- if not .PublishDate.IsZero }}
|
||||
@@ -23,16 +25,16 @@
|
||||
<meta property="article:author" content="https://www.facebook.com/{{ . }}">{{ end }}
|
||||
{{- with .Params.tags }}{{ range . }}
|
||||
<meta property="article:tag" content="{{ . }}">{{ end }}{{ end }}
|
||||
{{- end }}
|
||||
{{ end -}}
|
||||
|
||||
{{ with .Site.Author.facebookid }}<meta property="fb:admins" content="{{ . }}">{{ end }}
|
||||
{{ with .Site.Params.facebookAppID }}<meta property="fb:app_id" content="{{ . }}">{{ end }}
|
||||
|
||||
<meta name="twitter:card" content="{{ if .IsPage }}summary_large_image{{ else }}summary{{ end }}">
|
||||
<meta name="twitter:domain" content="{{ .Site.Params.domain }}">
|
||||
<meta name="twitter:domain" content="{{ (urls.Parse .Site.BaseURL).Host }}">
|
||||
{{- with .Site.Author.twitter }}
|
||||
<meta name="twitter:site" content="{{ printf "%s%s" "@" . }}">
|
||||
<meta name="twitter:creator" content="{{ printf "%s%s" "@" . }}">
|
||||
{{- end }}
|
||||
{{ end -}}
|
||||
{{ with .Site.Author.twitterid }}<meta name="twitter:creator_id" content="{{ . }}">{{ end }}
|
||||
<meta name="twitter:dnt" content="on">
|
||||
|
@@ -1,6 +1,5 @@
|
||||
{{ partial "head/schema/person" . -}}
|
||||
|
||||
{{ if and .IsPage (eq .Type .Site.Params.mainSection) }}
|
||||
{{ partial "head/schema/person" . }}
|
||||
{{ partial "head/schema/article" . }}
|
||||
{{ else }}
|
||||
{{ partial "head/schema/person" . }}
|
||||
{{ partial "head/schema/article" . -}}
|
||||
{{ end -}}
|
||||
|
@@ -17,19 +17,19 @@
|
||||
"publisher": {
|
||||
"@type": "Organization",
|
||||
"name": {{ .Site.Title }},
|
||||
"url": {{ .Site.BaseURL }},
|
||||
"url": {{ .Site.BaseURL }}{{ with .Scratch.Get "logoImage" }},
|
||||
"logo": {
|
||||
"@type": "ImageObject",
|
||||
"url": {{ .Scratch.Get "logoImage_url" | absURL }},
|
||||
"width": "{{ .Scratch.Get "logoImage_width" }}",
|
||||
"height": "{{ .Scratch.Get "logoImage_height" }}"
|
||||
}
|
||||
},
|
||||
"url": {{ .Permalink }},
|
||||
"width": "{{ .Width }}",
|
||||
"height": "{{ .Height }}"
|
||||
}{{ end }}
|
||||
}{{ with .Scratch.Get "pageImage" }},
|
||||
"image": {
|
||||
"@type": "ImageObject",
|
||||
"url": {{ .Scratch.Get "socialImage_url" | absURL }},
|
||||
"width": "{{ .Scratch.Get "socialImage_width" }}",
|
||||
"height": "{{ .Scratch.Get "socialImage_height" }}"
|
||||
}
|
||||
"url": {{ .Permalink }},
|
||||
"width": "{{ .Width }}",
|
||||
"height": "{{ .Height }}"
|
||||
}{{ end }}
|
||||
}
|
||||
</script>
|
||||
|
@@ -7,13 +7,13 @@
|
||||
"name": {{ .name }},
|
||||
"url": {{ $.Site.BaseURL }},
|
||||
"description": {{ $.Site.Params.description }},
|
||||
{{ with .jobtitle }}"jobTitle": {{ . }},{{ end }}
|
||||
{{ with .jobtitle }}"jobTitle": {{ . }},{{ end }}{{ with $.Scratch.Get "authorImage" }}
|
||||
"image": {
|
||||
"@type": "ImageObject",
|
||||
"url": {{ $.Scratch.Get "defaultImage_url" | absURL }},
|
||||
"width": "{{ $.Scratch.Get "defaultImage_width" }}",
|
||||
"height": "{{ $.Scratch.Get "defaultImage_height" }}"
|
||||
},
|
||||
"url": {{ .Permalink }},
|
||||
"width": "{{ .Width }}",
|
||||
"height": "{{ .Height }}"
|
||||
},{{ end }}
|
||||
"sameAs": [
|
||||
{{ $.Site.BaseURL }},
|
||||
{{ with .github }}{{ printf "%s%s" "https://github.com/" . }},{{ end }}
|
||||
|
@@ -2,9 +2,9 @@
|
||||
<link rel="stylesheet" href="{{ $style.Permalink }}">
|
||||
|
||||
{{/* Page-specific styles set via front matter, scoped via SCSS and inlined */}}
|
||||
{{ with .Params.css }}
|
||||
{{- with .Params.css -}}
|
||||
{{/* NOTE: This file doesn't end up getting published (which is good) */}}
|
||||
{{- $target := path.Join $.File.Dir "css/inline.scss" }}
|
||||
{{- $target := path.Join $.File.Dir "css/inline.scss" -}}
|
||||
{{- $css := . | resources.FromString $target | resources.ToCSS | resources.PostCSS (dict "config" "postcss.config.js") -}}
|
||||
|
||||
{{/* Already being minified to my taste by PostCSS above */}}
|
||||
@@ -13,4 +13,4 @@
|
||||
{{ $css.Content | safeCSS }}
|
||||
</style>
|
||||
{{- printf "<!-- htmlmin:ignore -->" | safeHTML }}
|
||||
{{ end }}
|
||||
{{ end -}}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
{{ with .Site.Params.webmention }}
|
||||
{{ with .Site.Params.webmentionIO }}
|
||||
<link rel="pingback" href="https://webmention.io/{{ . }}/xmlrpc">
|
||||
<link rel="webmention" href="https://webmention.io/{{ . }}/webmention">
|
||||
{{ end }}
|
||||
|
@@ -1,12 +1,10 @@
|
||||
<footer>
|
||||
<div class="row">
|
||||
<div id="copyright">Content <a class="no-underline" href="{{ "license/" | absURL }}"{{ with .Site.Params.licenseFull }} title="{{ . }}"{{ end }}>licensed under {{ .Site.Params.license }}</a>, {{ with .Site.Params.copyrightFirstYear }}<a class="no-underline" href="{{ "previously/" | absURL }}" title="Previously on...">{{ . }} –</a>{{ end }} {{ now.Format "2006" }}.</div>
|
||||
<!-- adblock hides images with width="88" and height="31", for some reason? using style="..." gets around it. -->
|
||||
<!-- TODO: ask about this..? https://github.com/AdguardTeam/AdguardFilters/blob/ba4db91022dbebe48967a447b5f818064ee60167/SpywareFilter/sections/general_elemhide.txt#L18 -->
|
||||
<div id="y2k"><a class="no-underline" href="https://y2k.land/" title="Made for Internet Explorer®" target="_blank" rel="noopener"><img src="{{ "img/ie.gif" | absURL }}" style="width: 88px; height: 31px;" alt="Made for Internet Explorer®"></a></div>
|
||||
<div id="poweredby">
|
||||
<a class="no-underline" href="https://gohugo.io/" title="Powered by Hugo" id="hugo" target="_blank" rel="noopener">Made with <span class="beat">❤</span> and Hugo.</a>
|
||||
{{ with .Site.Params.github }}<a class="no-underline" href="https://github.com/{{ . }}" title="View Source on GitHub" id="source" target="_blank" rel="noopener">View source.</a>{{ end }}
|
||||
{{ with .Site.Params.githubRepo }}<a class="no-underline" href="https://github.com/{{ . }}" title="View Source on GitHub" id="source" target="_blank" rel="noopener">View source.</a>{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
@@ -1,13 +1,13 @@
|
||||
<header>
|
||||
<nav>
|
||||
<a class="no-underline" href="{{ .Site.BaseURL }}" id="logo" rel="me author" aria-label="{{ .Site.Title }}">
|
||||
{{ partial "functions/inline-svg" (dict "src" "img/logo.svg" "width" 28 "height" 40) }}
|
||||
{{ if fileExists "assets/img/logo.svg" }}{{ partial "functions/inline-svg" (dict "src" "img/logo.svg" "width" 28 "height" 40) }}{{ end }}
|
||||
<h1 id="name">{{ .Site.Title }}</h1>
|
||||
</a>
|
||||
<ul>
|
||||
{{- range .Site.Menus.main }}
|
||||
<li><a class="no-underline" {{ printf "href=%q" .URL | safeHTMLAttr }} aria-label="{{ .Name }}"{{ if strings.HasPrefix .URL "http" }} target="_blank" rel="me noopener"{{ end }}><span class="icon">{{ .Pre }}</span><span class="text">{{ .Name }}</span></a></li>
|
||||
{{ end -}}
|
||||
{{- end }}
|
||||
<li><button class="dark-mode-toggle" title="Toggle Dark Mode" aria-label="Toggle Dark Mode"></button></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
@@ -1,20 +1,20 @@
|
||||
{{ $darkmode := resources.Get "js/dark-mode.js" | resources.ExecuteAsTemplate "js/dark-mode.js" . }}
|
||||
{{ $twemoji := resources.Get "vendor/emoji/emoji.js" | resources.ExecuteAsTemplate "vendor/emoji/emoji.min.js" . }}
|
||||
{{- $darkmode := resources.Get "js/dark-mode.js" | resources.ExecuteAsTemplate "js/dark-mode.js" . -}}
|
||||
{{- $twemoji := resources.Get "js/vendor/twemoji.js" | resources.ExecuteAsTemplate "js/vendor/twemoji.js" . -}}
|
||||
|
||||
{{ $bundle := slice $darkmode $twemoji }}
|
||||
{{- $bundle := slice $darkmode $twemoji -}}
|
||||
|
||||
{{/* only parse and append analytics script on production site */}}
|
||||
{{ $includeAnalytics := eq hugo.Environment "production" }}
|
||||
{{- $includeAnalytics := eq hugo.Environment "production" -}}
|
||||
|
||||
{{ if $includeAnalytics }}
|
||||
{{ $analytics := resources.Get "js/simple-analytics.js" | resources.ExecuteAsTemplate "js/simple-analytics.js" . }}
|
||||
{{ $bundle = slice $darkmode $twemoji $analytics }}
|
||||
{{ end }}
|
||||
{{- if $includeAnalytics }}
|
||||
{{- $analytics := resources.Get "js/analytics.js" | resources.ExecuteAsTemplate "js/analytics.js" . }}
|
||||
{{- $bundle = slice $darkmode $twemoji $analytics }}
|
||||
{{- end }}
|
||||
|
||||
{{ $js := $bundle | resources.Concat "/js/app.js" }}
|
||||
{{- $js := $bundle | resources.Concat "/js/app.js" -}}
|
||||
<script async defer src="{{ $js.Permalink }}"></script>
|
||||
|
||||
{{/* proxy to simple analytics noscript on production */}}
|
||||
{{ if $includeAnalytics }}
|
||||
{{- if $includeAnalytics }}
|
||||
<noscript><img src="{{ "sa/manual.gif" | absURL }}" alt=""></noscript>
|
||||
{{ end }}
|
||||
{{ end -}}
|
||||
|
Reference in New Issue
Block a user