mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-12-03 03:48:55 -05:00
lots of random cleanup & organization
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
{{/* Pull in assets processed by Webpack */}}
|
||||
{{- define "__head_css" -}}
|
||||
{{ with .Site.Data.manifest }}
|
||||
{{ with index . "main.css" }}
|
||||
<link rel="stylesheet" href="{{ .src | absURL }}">
|
||||
{{ 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 -}}
|
||||
<style>
|
||||
{{ $css.Content | safeCSS }}
|
||||
</style>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "__head_preload" -}}
|
||||
{{ with .Site.Data.manifest }}
|
||||
{{ with index . "fonts/inter-subset.var.woff2" }}
|
||||
<link rel="preload" href="{{ .src | absURL }}" as="font" type="font/woff2" crossorigin>
|
||||
{{ end }}
|
||||
{{ with index . "fonts/roboto-mono-subset.var.woff2" }}
|
||||
<link rel="preload" href="{{ .src | absURL }}" as="font" type="font/woff2" crossorigin>
|
||||
{{ end }}
|
||||
{{ with index . "main.js" }}
|
||||
<link rel="preload" href="{{ .src | absURL }}" as="script">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "__body_js" -}}
|
||||
<!-- inline the dark mode script to avoid a blinding flash of white background on loads -->
|
||||
<script>(function(d){var u=d.document,f=u.body.classList,e=localStorage,c="dark_mode_pref",t=e.getItem(c),a="dark",n="light",r="{{ .Site.Params.Theme.defaultTheme | safeJS }}",o=u.querySelector(".dark-mode-toggle"),i=r===a,b=function(d){f.remove(a,n);f.add(d);i=d===a};t===a&&b(a);t===n&&b(n);if(!t){var s=function(d){return"(prefers-color-scheme: "+d+")"};d.matchMedia(s(a)).matches?b(a):d.matchMedia(s(n)).matches?b(n):b(r);d.matchMedia(s(a)).addListener((function(d){d.matches&&b(a)}));d.matchMedia(s(n)).addListener((function(d){d.matches&&b(n)}))}if(o){o.style.display="block";o.addEventListener("click",(function(){if(i){b(n);e.setItem(c,n)}else{b(a);e.setItem(c,a)}}),!0)}})(window)</script>
|
||||
|
||||
{{ with .Site.Data.manifest }}
|
||||
{{ with index . "main.js" -}}
|
||||
<script async defer src="{{ .src | absURL }}" ></script>
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{/* 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.Data.manifest -}}
|
||||
{{- with index . $.Site.Author.image -}}
|
||||
{{- $.Scratch.Set "authorImage" (dict "Permalink" (absURL .src) "Width" 1200 "Height" 1200 "MediaType" "image/jpeg") -}}
|
||||
{{- 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.Data.manifest -}}
|
||||
{{- with index . $.Site.Params.image -}}
|
||||
{{- $.Scratch.Set "logoImage" (dict "Permalink" (absURL .src) "Width" 2048 "Height" 2048 "MediaType" "image/png") -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
19
layouts/partials/functions/prepare-css.html
Normal file
19
layouts/partials/functions/prepare-css.html
Normal file
@@ -0,0 +1,19 @@
|
||||
{{/* Pull in CSS processed by Webpack */}}
|
||||
|
||||
{{- define "__head_css" -}}
|
||||
{{ with .Site.Data.manifest }}
|
||||
{{ with index . "main.css" }}
|
||||
<link rel="stylesheet" href="{{ .src | absURL }}">
|
||||
{{ 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 -}}
|
||||
<style>
|
||||
{{ $css.Content | safeCSS }}
|
||||
</style>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
40
layouts/partials/functions/prepare-js.html
Normal file
40
layouts/partials/functions/prepare-js.html
Normal file
@@ -0,0 +1,40 @@
|
||||
{{/* Pull in JS processed by Webpack */}}
|
||||
|
||||
{{- define "__head_preload" -}}
|
||||
{{ with .Site.Data.manifest }}
|
||||
{{ with index . "fonts/inter-subset.var.woff2" }}
|
||||
<link rel="preload" href="{{ .src | absURL }}" as="font" type="font/woff2" crossorigin>
|
||||
{{ end }}
|
||||
{{ with index . "fonts/roboto-mono-subset.var.woff2" }}
|
||||
<link rel="preload" href="{{ .src | absURL }}" as="font" type="font/woff2" crossorigin>
|
||||
{{ end }}
|
||||
{{ with index . "main.js" }}
|
||||
<link rel="preload" href="{{ .src | absURL }}" as="script">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "__body_js" -}}
|
||||
{{ with .Site.Data.manifest }}
|
||||
{{ with index . "main.js" -}}
|
||||
<script async defer src="{{ .src | absURL }}"></script>
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{/* Detect shortcodes and append external scripts as needed once per page */}}
|
||||
{{ if .HasShortcode "gh-buttons" -}}
|
||||
{{ template "__shortcode_gh-buttons_js" $ }}
|
||||
{{ end -}}
|
||||
{{ if .HasShortcode "tweet" -}}
|
||||
{{ template "__shortcode_twitter_js" $ }}
|
||||
{{ end -}}
|
||||
{{ if .HasShortcode "facebook" -}}
|
||||
{{ template "__shortcode_facebook_js" $ }}
|
||||
{{ end -}}
|
||||
{{ if .HasShortcode "instagram" -}}
|
||||
{{ template "__shortcode_instagram_js" $ }}
|
||||
{{ end -}}
|
||||
{{ if .HasShortcode "vimeo" -}}
|
||||
{{ template "__shortcode_vimeo_js" $ }}
|
||||
{{ end -}}
|
||||
{{- end -}}
|
||||
39
layouts/partials/functions/prepare-meta.html
Normal file
39
layouts/partials/functions/prepare-meta.html
Normal file
@@ -0,0 +1,39 @@
|
||||
{{/* 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.Data.manifest -}}
|
||||
{{- with index . $.Site.Author.image -}}
|
||||
{{- $.Scratch.Set "authorImage" (dict "Permalink" (absURL .src) "Width" 1200 "Height" 1200 "MediaType" "image/jpeg") -}}
|
||||
{{- 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.Data.manifest -}}
|
||||
{{- with index . $.Site.Params.image -}}
|
||||
{{- $.Scratch.Set "logoImage" (dict "Permalink" (absURL .src) "Width" 2048 "Height" 2048 "MediaType" "image/png") -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -1,4 +1,3 @@
|
||||
{{ partial "functions/init" . -}}
|
||||
{{ partial "head/meta" . -}}
|
||||
{{ partial "head/open-graph" . -}}
|
||||
{{ partialCached "head/mobile" . -}}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{{ with .Site.GoogleAnalytics }}
|
||||
<script>
|
||||
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
|
||||
ga('create', '{{ . }}', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
<script async src="https://www.google-analytics.com/analytics.js"></script>
|
||||
{{ end }}
|
||||
@@ -1,19 +0,0 @@
|
||||
{{ if .Site.Params.PiwikServer }}
|
||||
<script>
|
||||
var _paq = window._paq || [];
|
||||
// tracker methods like "setCustomDimension" should be called before "trackPageView"
|
||||
_paq.push(['setRequestMethod', 'POST']);
|
||||
_paq.push(['setSecureCookie', true]);
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
_paq.push(['enableHeartBeatTimer']);
|
||||
(function() {
|
||||
var u="{{ .Site.Params.PiwikServer }}";
|
||||
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
||||
_paq.push(['setSiteId', '{{ .Site.Params.PiwikSiteId }}']);
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
</script>
|
||||
<noscript><img src="{{ .Site.Params.PiwikServer }}/send?idsite={{ .Site.Params.PiwikSiteId }}&rec={{ .Site.Params.PiwikSiteId }}" alt=""></noscript>
|
||||
{{ end }}
|
||||
@@ -1,19 +0,0 @@
|
||||
{{ if .HasShortcode "gh-buttons" -}}
|
||||
{{ template "__shortcode_gh-buttons_js" $ }}
|
||||
{{ end -}}
|
||||
|
||||
{{ if .HasShortcode "tweet" -}}
|
||||
{{ template "__shortcode_twitter_js" $ }}
|
||||
{{ end -}}
|
||||
|
||||
{{ if .HasShortcode "facebook" -}}
|
||||
{{ template "__shortcode_facebook_js" $ }}
|
||||
{{ end -}}
|
||||
|
||||
{{ if .HasShortcode "instagram" -}}
|
||||
{{ template "__shortcode_instagram_js" $ }}
|
||||
{{ end -}}
|
||||
|
||||
{{ if .HasShortcode "vimeo" -}}
|
||||
{{ template "__shortcode_vimeo_js" $ }}
|
||||
{{ end -}}
|
||||
@@ -1,2 +0,0 @@
|
||||
<script async defer src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
|
||||
<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt=""/></noscript>
|
||||
@@ -1,2 +0,0 @@
|
||||
{{/* optional feature, see: https://docs.simpleanalytics.com/events */}}
|
||||
<script>window.sa_event=window.sa_event||function(){a=[].slice.call(arguments);sa_event.q?sa_event.q.push(a):sa_event.q=[a]};</script>
|
||||
Reference in New Issue
Block a user