From d51ea9c4f451368deedc29f58465c1c0fcf3cc58 Mon Sep 17 00:00:00 2001 From: Rin Date: Sun, 29 Jan 2023 23:07:03 +1100 Subject: [PATCH] fix instant-page-loader --- layouts/partials/head.html | 157 ++++++++++++++++++++++++++++++++++ static/instant.page.v5.1.1.js | 3 + 2 files changed, 160 insertions(+) create mode 100644 layouts/partials/head.html create mode 100644 static/instant.page.v5.1.1.js diff --git a/layouts/partials/head.html b/layouts/partials/head.html new file mode 100644 index 0000000..92b9ac4 --- /dev/null +++ b/layouts/partials/head.html @@ -0,0 +1,157 @@ + + {{/* Instant Page Script */}} + {{/* Optimised by A Friend */}} + + + + {{ with .Site.Language.Params.htmlCode | default .Site.LanguageCode }} + + {{ end }} + + + {{/* Title */}} + {{ if .IsHome -}} + {{ .Site.Title | emojify }} + + {{- else -}} + {{ .Title | emojify }} · {{ .Site.Title | emojify }} + + {{- end }} + {{/* Metadata */}} + {{ with .Site.Params.description -}} + + {{- end }} + {{ with .Site.Params.keywords -}} + + {{- end }} + {{ with .Site.Params.robots }} + + {{ end }} + {{ with .Params.robots }} + + {{ end }} + + {{ range .AlternativeOutputFormats -}} + {{ printf ` + ` .Rel .MediaType.Type .RelPermalink ($.Site.Title | emojify) | + safeHTML }} + {{ end -}} + {{/* Asset bundles */}} + {{ $assets := newScratch }} + {{ $cssScheme := resources.Get (printf "css/schemes/%s.css" (.Site.Params.colorScheme | default "blowfish")) }} + {{ if not $cssScheme }} + {{ $cssScheme = resources.Get "css/schemes/blowfish.css" }} + {{ end }} + {{ $assets.Add "css" (slice $cssScheme) }} + {{ $cssMain := resources.Get "css/compiled/main.css" }} + {{ $assets.Add "css" (slice $cssMain) }} + {{ $cssCustom := resources.Get "css/custom.css" }} + {{ if $cssCustom }} + {{ $assets.Add "css" (slice $cssCustom) }} + {{ end }} + {{ $bundleCSS := $assets.Get "css" | resources.Concat "css/main.bundle.css" | resources.Minify | resources.Fingerprint + "sha512" }} + + {{ $jsAppearance := resources.Get "js/appearance.js" }} + {{ $jsAppearance = $jsAppearance | resources.Minify | resources.Fingerprint "sha512" }} + + {{ if .Site.Params.enableSearch | default false }} + {{ $jsFuse := resources.Get "lib/fuse/fuse.min.js" }} + {{ $jsSearch := resources.Get "js/search.js" }} + {{ $assets.Add "js" (slice $jsFuse $jsSearch) }} + {{ end }} + {{ if .Site.Params.enableCodeCopy | default false }} + {{ $jsCode := resources.Get "js/code.js" }} + {{ $assets.Add "js" (slice $jsCode) }} + {{ end }} + {{ if .Site.Params.rtl | default false }} + {{ $jsRTL := resources.Get "js/rtl.js" }} + {{ $assets.Add "js" (slice $jsRTL) }} + {{ end }} + {{ if $assets.Get "js" }} + {{ $bundleJS := $assets.Get "js" | resources.Concat "js/main.bundle.js" | resources.Minify | resources.Fingerprint + "sha512" }} + + {{ end }} + + {{/* Icons */}} + {{ if templates.Exists "partials/favicons.html" }} + {{ partialCached "favicons.html" .Site }} + {{ else }} + + + + + {{ end }} + {{/* Site Verification */}} + {{ with .Site.Params.verification.google }} + + {{ end }} + {{ with .Site.Params.verification.bing }} + + {{ end }} + {{ with .Site.Params.verification.pinterest }} + + {{ end }} + {{ with .Site.Params.verification.yandex }} + + {{ end }} + {{/* Social */}} + {{ template "_internal/opengraph.html" . }} + {{ template "_internal/twitter_cards.html" . }} + {{/* Schema */}} + {{ partial "schema.html" . }} + {{/* Me */}} + {{ with .Site.Author.name }} + {{ end }} + {{ with .Site.Author.links }} + {{ range $links := . }} + {{ range $name, $url := $links }} + {{ end }} + {{ end }} + {{ end }} + {{/* Vendor */}} + {{ partial "vendor.html" . }} + {{/* Analytics */}} + {{ partialCached "analytics.html" .Site }} + {{/* Extend head - eg. for custom analytics scripts, etc. */}} + {{ if templates.Exists "partials/extend-head.html" }} + {{ partialCached "extend-head.html" .Site }} + {{ end }} + + {{/* Firebase */}} + {{ with $.Site.Params.firebase }} + {{ if isset $.Site.Params "firebase" }} + + + + + {{ end }} + {{ end }} + diff --git a/static/instant.page.v5.1.1.js b/static/instant.page.v5.1.1.js new file mode 100644 index 0000000..fd4ae35 --- /dev/null +++ b/static/instant.page.v5.1.1.js @@ -0,0 +1,3 @@ +/*! instant.page v5.1.1 - (C) 2019-2020 Alexandre Dieulot - https://instant.page/license */ +/* Modified by Rin - https://rin.systems/ */ +let z,x;const n=new Set,o=document.createElement("link"),i=o.relList&&o.relList.supports&&o.relList.supports("prefetch")&&window.IntersectionObserver&&"isIntersecting"in IntersectionObserverEntry.prototype,s="instantAllowQueryString"in document.body.dataset,a="instantAllowExternalLinks"in document.body.dataset,r="instantWhitelist"in document.body.dataset,c="instantMousedownShortcut"in document.body.dataset,d=1111;let l=65,u=!1,f=!1,m=!1;if("instantIntensity"in document.body.dataset){const t=document.body.dataset.instantIntensity;if("mousedown"==t.substr(0,"mousedown".length))u=!0,"mousedown-only"==t&&(f=!0);else if("viewport"==t.substr(0,"viewport".length))navigator.connection&&(navigator.connection.saveData||navigator.connection.effectiveType&&navigator.connection.effectiveType.includes("2g"))||("viewport"==t?document.documentElement.clientWidth*document.documentElement.clientHeight<45e4&&(m=!0):"viewport-all"==t&&(m=!0));else{const e=parseInt(t);isNaN(e)||(l=e)}}if(i){const t={capture:!0,passive:!0};if(f||document.addEventListener("touchstart",(function(t){x=performance.now();const e=t.target.closest("a");h(e)&&v(e.href)}),t),u?c||document.addEventListener("mousedown",(function(t){const e=t.target.closest("a");h(e)&&v(e.href)}),t):document.addEventListener("mouseover",(function(t){if(performance.now()-x{v(e.href),z=void 0}),l))}),t),c&&document.addEventListener("mousedown",(function(t){if(performance.now()-x1||t.metaKey||t.ctrlKey)return;if(!e)return;e.addEventListener("click",(function(t){1337!=t.detail&&t.preventDefault()}),{capture:!0,passive:!1,once:!0});const n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1,detail:1337});e.dispatchEvent(n)}),t),m){let t;(t=window.requestIdleCallback?t=>{requestIdleCallback(t,{timeout:1500})}:t=>{t()})((()=>{const t=new IntersectionObserver((e=>{e.forEach((e=>{if(e.isIntersecting){const n=e.target;t.unobserve(n),v(n.href)}}))}));document.querySelectorAll("a").forEach((e=>{h(e)&&t.observe(e)}))}))}}function p(t){t.relatedTarget&&t.target.closest("a")==t.relatedTarget.closest("a")||z&&(clearTimeout(z),z=void 0)}function h(t){if(t&&t.href&&(!r||"instant"in t.dataset)&&(a||t.origin==location.origin||"instant"in t.dataset)&&["http:","https:"].includes(t.protocol)&&("http:"!=t.protocol||"https:"!=location.protocol)&&(s||!t.search||"instant"in t.dataset)&&!(t.hash&&t.pathname+t.search==location.pathname+location.search||"noInstant"in t.dataset))return!0}function v(t){if(n.has(t))return;const e=document.createElement("link");e.rel="prefetch",e.href=t,document.head.appendChild(e),n.add(t)} \ No newline at end of file