From 8c5d10925e591c909e98c9a413e10b2e47c15b6d Mon Sep 17 00:00:00 2001 From: Reorx Date: Sat, 9 Apr 2022 23:31:15 +0800 Subject: [PATCH 01/15] allow customize post page width --- assets/css/common/main.css | 5 +++++ assets/css/core/theme-vars.css | 3 ++- layouts/_default/baseof.html | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/assets/css/common/main.css b/assets/css/common/main.css index 50022ac..22dc39c 100644 --- a/assets/css/common/main.css +++ b/assets/css/common/main.css @@ -1,3 +1,4 @@ +/* for home and other pages */ .main { position: relative; min-height: calc(100vh - var(--header-height) - var(--footer-height)); @@ -5,6 +6,10 @@ margin: auto; padding: var(--gap); } +/* for post page */ +.main.post { + max-width: calc(var(--post-width) + var(--gap) * 2); +} .page-header h1 { font-size: 40px; diff --git a/assets/css/core/theme-vars.css b/assets/css/core/theme-vars.css index fd0c5ee..955b7e4 100644 --- a/assets/css/core/theme-vars.css +++ b/assets/css/core/theme-vars.css @@ -1,8 +1,9 @@ :root { --gap: 24px; --content-gap: 20px; - --nav-width: 1024px; + --nav-width: 960px; --main-width: 720px; + --post-width: 800px; --header-height: 60px; --footer-height: 60px; --radius: 8px; diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 3d13f07..edd7809 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -14,7 +14,7 @@ {{- end -}} " id="top"> {{- partialCached "header.html" . .Page -}} -
+
{{- block "main" . }}{{ end }}
{{ partialCached "footer.html" . .Layout .Kind (.Param "hideFooter") (.Param "ShowCodeCopyButtons") -}} From 60f139d529a00c90a75151912f3639060435a1d9 Mon Sep 17 00:00:00 2001 From: Reorx Date: Sat, 9 Apr 2022 23:59:22 +0800 Subject: [PATCH 02/15] add side class for toc if TocSide is true --- assets/css/common/post-single.css | 15 ++++++++++----- layouts/partials/toc.html | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/assets/css/common/post-single.css b/assets/css/common/post-single.css index b9b9709..07be079 100644 --- a/assets/css/common/post-single.css +++ b/assets/css/common/post-single.css @@ -263,20 +263,25 @@ border-radius: var(--radius); padding: 0.4em; } +@media screen and (min-width: 1000px) { + .toc.side { + position: fixed; + right: 50px; + top: 100px; + width: 300px; + font-size: .9em; + } +} .dark .toc { background: var(--entry); } .toc details summary { - cursor: zoom-in; + cursor: pointer; margin-inline-start: 20px; } -.toc details[open] summary { - cursor: zoom-out; -} - .toc .details { display: inline; font-weight: 500; diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html index d9b8b23..02a61e9 100644 --- a/layouts/partials/toc.html +++ b/layouts/partials/toc.html @@ -1,7 +1,7 @@ {{- $headers := findRE "(.|\n])+?" .Content -}} {{- $has_headers := ge (len $headers) 1 -}} {{- if $has_headers -}} -
+
{{- i18n "toc" | default "Table of Contents" }} From 9ebe2111f67c2684d3dcfa9f9e739890c7d7d54b Mon Sep 17 00:00:00 2001 From: Reorx Date: Sun, 10 Apr 2022 01:18:40 +0800 Subject: [PATCH 03/15] active toc link while scrolling --- assets/css/common/post-single.css | 4 +++ layouts/partials/footer.html | 49 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/assets/css/common/post-single.css b/assets/css/common/post-single.css index 07be079..62be1bb 100644 --- a/assets/css/common/post-single.css +++ b/assets/css/common/post-single.css @@ -270,6 +270,7 @@ top: 100px; width: 300px; font-size: .9em; + z-index: 1; } } @@ -295,6 +296,9 @@ .toc li ul { margin-inline-start: var(--gap); } +.toc li a.active { + text-decoration: underline; +} .toc summary:focus { outline: 0; diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index d76058f..d533987 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -133,3 +133,52 @@ }); {{- end }} + +{{- if (and (eq .Kind "page") (.Param "ShowToc") (.Param "TocSide")) }} + +{{- end }} From 829bb016914e55405c56c3c2a0d5488c1a02ecae Mon Sep 17 00:00:00 2001 From: Reorx Date: Sun, 10 Apr 2022 01:19:23 +0800 Subject: [PATCH 04/15] enhance toc scroll algorithm --- layouts/partials/footer.html | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index d533987..f5f04cf 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -138,14 +138,11 @@ From d50ce4575db054c1873e659c57a7ff1636b067e5 Mon Sep 17 00:00:00 2001 From: Reorx Date: Sun, 10 Apr 2022 17:43:04 +0800 Subject: [PATCH 05/15] add param DisableSmoothScroll --- layouts/partials/footer.html | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index f5f04cf..9415aaa 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -24,6 +24,7 @@ {{- partial "extend_footer.html" . }} {{- if (not site.Params.disableScrollToTop) }} From d7f6d6a7734b658b28c543b403810d397bbb6070 Mon Sep 17 00:00:00 2001 From: Reorx Date: Sun, 10 Apr 2022 17:47:41 +0800 Subject: [PATCH 06/15] use setTimeout to reduce scroll callback frequency --- layouts/partials/footer.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 9415aaa..a9d9d7b 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -146,7 +146,7 @@ window.addEventListener('DOMContentLoaded', function (event) { let activeHeading = headings[0]; getLinkByHeading(activeHeading).classList.add(activeClass); - window.addEventListener('scroll', () => { + const onScroll = () => { const passedHeadings = []; for (const h of headings) { // 5 px as a buffer @@ -166,6 +166,14 @@ window.addEventListener('DOMContentLoaded', function (event) { activeHeading = newActiveHeading; getLinkByHeading(activeHeading).classList.add(activeClass); } + } + + let timer = null; + window.addEventListener('scroll', () => { + if (timer !== null) { + clearTimeout(timer) + } + timer = setTimeout(onScroll, 50) }, false); function getLinkByHeading(heading) { From 7dc044f2ba55a7f1eed37ebc6446f46b71f57ea0 Mon Sep 17 00:00:00 2001 From: Reorx Date: Sun, 10 Apr 2022 20:38:20 +0800 Subject: [PATCH 07/15] tweak toc style --- assets/css/common/post-single.css | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/assets/css/common/post-single.css b/assets/css/common/post-single.css index 62be1bb..8730e88 100644 --- a/assets/css/common/post-single.css +++ b/assets/css/common/post-single.css @@ -69,8 +69,7 @@ font-size: 12px; } -.post-content a, -.toc a:hover { +.post-content a { box-shadow: 0 1px 0; } @@ -266,7 +265,7 @@ @media screen and (min-width: 1000px) { .toc.side { position: fixed; - right: 50px; + right: 30px; top: 100px; width: 300px; font-size: .9em; @@ -297,6 +296,9 @@ margin-inline-start: var(--gap); } .toc li a.active { + box-shadow: 0 2px 0 var(--secondary); +} +.toc a:hover { text-decoration: underline; } From ef802995804ee7f7a18cc716cc689b141236daaa Mon Sep 17 00:00:00 2001 From: Reorx Date: Sun, 10 Apr 2022 23:40:31 +0800 Subject: [PATCH 08/15] add EnableInstantPage param --- assets/js/instantpage.js | 2 ++ layouts/partials/head.html | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 assets/js/instantpage.js diff --git a/assets/js/instantpage.js b/assets/js/instantpage.js new file mode 100644 index 0000000..a2a5ea3 --- /dev/null +++ b/assets/js/instantpage.js @@ -0,0 +1,2 @@ +/*! instant.page v5.1.0 - (C) 2019-2020 Alexandre Dieulot - https://instant.page/license */ +let t,e;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 n={capture:!0,passive:!0};if(f||document.addEventListener("touchstart",function(t){e=performance.now();const n=t.target.closest("a");if(!h(n))return;v(n.href)},n),u?c||document.addEventListener("mousedown",function(t){const e=t.target.closest("a");if(!h(e))return;v(e.href)},n):document.addEventListener("mouseover",function(n){if(performance.now()-e{v(o.href),t=void 0},l)},n),c&&document.addEventListener("mousedown",function(t){if(performance.now()-e1||t.metaKey||t.ctrlKey)return;if(!n)return;n.addEventListener("click",function(t){1337!=t.detail&&t.preventDefault()},{capture:!0,passive:!1,once:!0});const o=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1,detail:1337});n.dispatchEvent(o)},n),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(e){e.relatedTarget&&e.target.closest("a")==e.relatedTarget.closest("a")||t&&(clearTimeout(t),t=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)} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index b921452..ecce55c 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -151,3 +151,11 @@ {{- template "partials/templates/twitter_cards.html" . }} {{- template "partials/templates/schema_json.html" . }} {{- end -}} + +{{- /* InstantPage.js */}} +{{- if (.Param "EnableInstantPage") }} +{{- $instantpage := slice (resources.Get "js/instantpage.js") | resources.Concat "assets/js/instantpage.js" | minify }} + +{{- end }} From b7a046b0c2d8b171b8a6130e65ddc17ad5cf6d96 Mon Sep 17 00:00:00 2001 From: Reorx Date: Sun, 10 Apr 2022 23:41:00 +0800 Subject: [PATCH 09/15] add some simple icons with `-simple` suffix --- layouts/partials/svg.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/layouts/partials/svg.html b/layouts/partials/svg.html index 0583736..a1b598e 100644 --- a/layouts/partials/svg.html +++ b/layouts/partials/svg.html @@ -191,6 +191,8 @@ d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"> +{{- else if (eq $icon_name "github-simple") -}} +GitHub {{- else if (eq $icon_name "gitlab") -}} @@ -394,6 +396,8 @@ +{{- else if (eq $icon_name "rss-simple") -}} +RSS {{- else if (eq $icon_name "serverfault") -}} +{{- else if (eq $icon_name "telegram-simple") -}} +Telegram {{- else if (eq $icon_name "twitch") -}} @@ -481,6 +487,8 @@ d="M23 3a10.9 10.9 0 0 1-3.14 1.53 4.48 4.48 0 0 0-7.86 3v1A10.66 10.66 0 0 1 3 4s-4 9 5 13a11.64 11.64 0 0 1-7 2c9 5 20 0 20-11.5a4.5 4.5 0 0 0-.08-.83A7.72 7.72 0 0 0 23 3z"> +{{- else if (eq $icon_name "twitter-simple") -}} +Twitter {{- else if (eq $icon_name "unsplash") -}} +{{- else if (eq $icon_name "pinboard-simple") -}} +Pinboard {{- else if $icon_name -}} From 0bd381de0118bd63bd1207b970ce021e58eb89bd Mon Sep 17 00:00:00 2001 From: Reorx Date: Sun, 10 Apr 2022 23:41:50 +0800 Subject: [PATCH 10/15] fork: update footer --- layouts/partials/footer.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index a9d9d7b..e00d242 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -4,11 +4,11 @@ {{ site.Copyright | markdownify }} {{- else }} © {{ now.Year }} {{ site.Title }} - {{- end }} - + {{- end -}} + Powered by Hugo & - PaperMod + PaperMod {{- end }} From 8c37662b321192b73744d35a3138b5365956b933 Mon Sep 17 00:00:00 2001 From: Reorx Date: Mon, 11 Apr 2022 00:54:50 +0800 Subject: [PATCH 11/15] menu consistant font weight so that the width is also consistant --- assets/css/common/header.css | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/css/common/header.css b/assets/css/common/header.css index 3cd070e..4c8de8f 100644 --- a/assets/css/common/header.css +++ b/assets/css/common/header.css @@ -67,10 +67,12 @@ body:not(.dark) #sun { #menu a { font-size: 16px; + font-weight: 500; + color: var(--secondary); } #menu .active { - font-weight: 500; + color: var(--primary); border-bottom: 2px solid currentColor; } From b9bc8b7d3b94aa90c3c7d8137709cb1154df51ba Mon Sep 17 00:00:00 2001 From: Reorx Date: Mon, 11 Apr 2022 15:31:36 +0800 Subject: [PATCH 12/15] replace instantpage with instantclick --- assets/css/common/footer.css | 5 +++++ assets/js/instantclick.js | 13 +++++++++++++ assets/js/instantpage.js | 2 -- layouts/partials/footer.html | 13 ++++++++++++- layouts/partials/head.html | 8 -------- 5 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 assets/js/instantclick.js delete mode 100644 assets/js/instantpage.js diff --git a/assets/css/common/footer.css b/assets/css/common/footer.css index 5addb1e..b0dc264 100644 --- a/assets/css/common/footer.css +++ b/assets/css/common/footer.css @@ -58,3 +58,8 @@ #theme-toggle:focus { outline: 0; } + +/* InstantClick css */ +#instantclick-bar { + background: var(--tertiary); +} diff --git a/assets/js/instantclick.js b/assets/js/instantclick.js new file mode 100644 index 0000000..a2539d8 --- /dev/null +++ b/assets/js/instantclick.js @@ -0,0 +1,13 @@ +/* InstantClick 3.1.0 | (C) 2014 Alexandre Dieulot | http://instantclick.io/license */ +var InstantClick=function(d,e){function w(a){var b=a.indexOf("#");return 0>b?a:a.substr(0,b)}function z(a){for(;a&&"A"!=a.nodeName;)a=a.parentNode;return a}function A(a){var b=e.protocol+"//"+e.host;if(!(b=a.target||a.hasAttribute("download")||0!=a.href.indexOf(b+"/")||-1+new Date-500||(a=z(a.target))&&A(a)&&x(a.href)}function N(a){G>+new Date-500||(a=z(a.target))&&A(a)&&(a.addEventListener("mouseout",T),H?(O=a.href,l=setTimeout(x,H)):x(a.href))}function U(a){G=+new Date;(a=z(a.target))&&A(a)&&(D?a.removeEventListener("mousedown", +M):a.removeEventListener("mouseover",N),x(a.href))}function V(a){var b=z(a.target);!b||!A(b)||1p.readyState)&&0!=p.status){q.ready=+new Date-q.start;if(p.getResponseHeader("Content-Type").match(/\/(x|ht|xht)ml/)){var a=d.implementation.createHTMLDocument("");a.documentElement.innerHTML=p.responseText.replace(//gi,"");y=a.title; +u=a.body;var b=t("receive",r,u,y);b&&("body"in b&&(u=b.body),"title"in b&&(y=b.title));b=w(r);h[b]={body:u,title:y,scrollY:b in h?h[b].scrollY:0};for(var a=a.head.children,b=0,c,g=a.length-1;0<=g;g--)if(c=a[g],c.hasAttribute("data-instant-track")){c=c.getAttribute("href")||c.getAttribute("src")||c.innerHTML;for(var e=E.length-1;0<=e;e--)E[e]==c&&b++}b!=E.length&&(F=!0)}else F=!0;m&&(m=!1,P(r))}}function L(a){d.body.addEventListener("touchstart",U,!0);D?d.body.addEventListener("mousedown",M,!0):d.body.addEventListener("mouseover", +N,!0);d.body.addEventListener("click",V,!0);if(!a){a=d.body.getElementsByTagName("script");var b,c,g,e;i=0;for(j=a.length;i+new Date-(q.start+q.display)||(l&&(clearTimeout(l),l=!1),a||(a=O),v&&(a==r||m))||(v=!0,m=!1,r=a,F=u=!1,q={start:+new Date},t("fetch"), +p.open("GET",a),p.send())}function P(a){"display"in q||(q.display=+new Date-q.start);l||!v?l&&r&&r!=a?e.href=a:(x(a),C.start(0,!0),t("wait"),m=!0):m?e.href=a:F?e.href=r:u?(h[k].scrollY=pageYOffset,m=v=!1,K(y,u,r)):(C.start(0,!0),t("wait"),m=!0)}var I=navigator.userAgent,S=-1b;b++)a[b]+"Transform"in h.style&&(k=a[b]+"Transform");var c="transition";if(!(c in h.style))for(b=0;3>b;b++)a[b]+"Transition"in +h.style&&(c="-"+a[b].toLowerCase()+"-"+c);a=d.createElement("style");a.innerHTML="#instantclick{position:"+(Q?"absolute":"fixed")+";top:0;left:0;width:100%;pointer-events:none;z-index:2147483647;"+c+":opacity .25s .1s}.instantclick-bar{background:#29d;width:100%;margin-left:-100%;height:2px;"+c+":all .25s}";d.head.appendChild(a);Q&&(m(),addEventListener("resize",m),addEventListener("scroll",m))},start:a,done:e}}(),R="pushState"in history&&(!I.match("Android")||I.match("Chrome/"))&&"file:"!=e.protocol; +return{supported:R,init:function(){if(!k)if(R){for(var a=arguments.length-1;0<=a;a--){var b=arguments[a];!0===b?J=!0:"mousedown"==b?D=!0:"number"==typeof b&&(H=b)}k=w(e.href);h[k]={body:d.body,title:d.title,scrollY:pageYOffset};for(var b=d.head.children,c,a=b.length-1;0<=a;a--)c=b[a],c.hasAttribute("data-instant-track")&&(c=c.getAttribute("href")||c.getAttribute("src")||c.innerHTML,E.push(c));p=new XMLHttpRequest;p.addEventListener("readystatechange",W);L(!0);C.init();t("change",!0);addEventListener("popstate", +function(){var a=w(e.href);a!=k&&(a in h?(h[k].scrollY=pageYOffset,k=a,K(h[a].title,h[a].body,!1,h[a].scrollY)):e.href=e.href)})}else t("change",!0)},on:function(a,b){B[a].push(b)}}}(document,location); diff --git a/assets/js/instantpage.js b/assets/js/instantpage.js deleted file mode 100644 index a2a5ea3..0000000 --- a/assets/js/instantpage.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! instant.page v5.1.0 - (C) 2019-2020 Alexandre Dieulot - https://instant.page/license */ -let t,e;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 n={capture:!0,passive:!0};if(f||document.addEventListener("touchstart",function(t){e=performance.now();const n=t.target.closest("a");if(!h(n))return;v(n.href)},n),u?c||document.addEventListener("mousedown",function(t){const e=t.target.closest("a");if(!h(e))return;v(e.href)},n):document.addEventListener("mouseover",function(n){if(performance.now()-e{v(o.href),t=void 0},l)},n),c&&document.addEventListener("mousedown",function(t){if(performance.now()-e1||t.metaKey||t.ctrlKey)return;if(!n)return;n.addEventListener("click",function(t){1337!=t.detail&&t.preventDefault()},{capture:!0,passive:!1,once:!0});const o=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1,detail:1337});n.dispatchEvent(o)},n),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(e){e.relatedTarget&&e.target.closest("a")==e.relatedTarget.closest("a")||t&&(clearTimeout(t),t=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)} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index e00d242..4e348be 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -34,7 +34,9 @@ } const disableSmoothScroll = '{{- if (.Param "DisableSmoothScroll") -}}1{{- end -}}' == '1'; - if (window.matchMedia('(prefers-reduced-motion: reduce)').matches || disableSmoothScroll) { + const enableInstantClick = '{{- if (.Param "EnableInstantClick") -}}1{{- end -}}' == '1'; + // instant click and smooth scroll are mutually exclusive + if (window.matchMedia('(prefers-reduced-motion: reduce)').matches || disableSmoothScroll || enableInstantClick) { return; } // only run this code if smooth scroll should be enabled @@ -191,3 +193,12 @@ window.addEventListener('DOMContentLoaded', function (event) { }, false); {{- end }} + +{{- /* InstantClick.js */}} +{{- if (.Param "EnableInstantClick") }} +{{- $instantclick := slice (resources.Get "js/instantclick.js") | resources.Concat "assets/js/instantclick.js" | minify }} + + +{{- end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index ecce55c..b921452 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -151,11 +151,3 @@ {{- template "partials/templates/twitter_cards.html" . }} {{- template "partials/templates/schema_json.html" . }} {{- end -}} - -{{- /* InstantPage.js */}} -{{- if (.Param "EnableInstantPage") }} -{{- $instantpage := slice (resources.Get "js/instantpage.js") | resources.Concat "assets/js/instantpage.js" | minify }} - -{{- end }} From da84a0302b8dcb2a5146ab1f9f1477ee4a6e03aa Mon Sep 17 00:00:00 2001 From: Reorx Date: Mon, 11 Apr 2022 16:11:55 +0800 Subject: [PATCH 13/15] update readme --- README.md | 97 ++++++------------------------------------------------- 1 file changed, 9 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index ce755c7..d247e6a 100644 --- a/README.md +++ b/README.md @@ -1,90 +1,11 @@ -

Hugo PaperMod | Demo

+# PaperModX -

☄️ Fast | ☁️ Fluent | 🌙 Smooth | 📱 Responsive

-
+PaperModX is a forked version of [PaperMod](https://github.com/adityatelange/hugo-PaperMod), +it aims at adding new features and improving code quality, +makes it easier to read and modify by anyone with basic knowledge of Hugo and HTML. -> Hugo PaperMod is a theme based on [hugo-paper](https://github.com/nanxiaobei/hugo-paper). -> The goal of this project is to add more features and customization to the og theme. - -The [demo](https://adityatelange.github.io/hugo-PaperMod/) includes a lot of documentation about Installation, Features with a few more stuff. Make sure you visit it, to get an awesome hands-on experience and get to know about the features ... - -**ExampleSite** can be found here: [exampleSite](https://github.com/adityatelange/hugo-PaperMod/tree/exampleSite). Demo is built up with [exampleSite](https://github.com/adityatelange/hugo-PaperMod/tree/exampleSite) as source. - -[![Minimum Hugo Version](https://img.shields.io/static/v1?label=min-HUGO-version&message=0.83.0&color=blue&logo=hugo)](https://github.com/gohugoio/hugo/releases/tag/v0.83.0) -[![Build GH-Pages](https://github.com/adityatelange/hugo-PaperMod/workflows/Build%20GH-Pages/badge.svg)](https://github.com/adityatelange/hugo-PaperMod/deployments/activity_log?environment=github-pages) -[![GitHub](https://img.shields.io/github/license/adityatelange/hugo-PaperMod)](https://github.com/adityatelange/hugo-PaperMod/blob/master/LICENSE) -[![hugo-papermod](https://img.shields.io/badge/Hugo--Themes-@PaperMod-blue)](https://themes.gohugo.io/themes/hugo-papermod/) -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=adityatelange_hugo-PaperMod&metric=alert_status)](https://sonarcloud.io/dashboard?id=adityatelange_hugo-PaperMod) -![code-size](https://img.shields.io/github/languages/code-size/adityatelange/hugo-PaperMod) - ---- - -

- Mockup image -

- ---- - -## Features/Mods 💥 - -- Uses Hugo's asset generator with pipelining, fingerprinting, bundling and minification by default. -- 3 Modes: - - [Regular Mode.](https://github.com/adityatelange/hugo-PaperMod/wiki/Features#regular-mode-default-mode) - - [Home-Info Mode.](https://github.com/adityatelange/hugo-PaperMod/wiki/Features#home-info-mode) - - [Profile Mode.](https://github.com/adityatelange/hugo-PaperMod/wiki/Features#profile-mode) -- Table of Content Generation (newer implementation). -- Archive of posts. -- Social Icons (home-info and profile-mode) -- Social-Media Share buttons on posts. -- Menu location indicator. -- Multilingual support. (with language selector) -- Taxonomies -- Cover image for each post (with Responsive image support). -- Light/Dark theme (automatic theme switch a/c to browser theme and theme-switch button). -- SEO Friendly. -- Multiple Author support. -- Search Page with Fuse.js -- Other Posts suggestion below a post -- Breadcrumb Navigation -- Code Block Copy buttons -- No webpack, nodejs and other dependencies are required to edit the theme. - -Read Wiki For More Details => **[PaperMod - Features](https://github.com/adityatelange/hugo-PaperMod/wiki/Features)** - ---- - -## Install/Update 📥 - -Read Wiki For More Details => **[PaperMod - Installation](https://github.com/adityatelange/hugo-PaperMod/wiki/Installation)** - ---- - -## Social-Icons/Share-Icons 🖼️ - -Read Wiki For More Details => **[PaperMod-Icons](https://github.com/adityatelange/hugo-PaperMod/wiki/Icons)** - ---- - -## FAQs / How To's Guide 🙋 - -Read Wiki For More Details => **[PaperMod-FAQs](https://github.com/adityatelange/hugo-PaperMod/wiki/FAQs)** - ---- - -## Release Changelog - -Release ChangeLog has info about stuff added: **[Releases](https://github.com/adityatelange/hugo-PaperMod/releases)** - ---- - -## [Pagespeed Insights (100% ?)](https://pagespeed.web.dev/report?url=https://adityatelange.github.io/hugo-PaperMod/) - ---- - -## Special Thanks 🌟 - -- [**Highlight.js**](https://github.com/highlightjs/highlight.js) -- [**Fuse.js**](https://github.com/krisk/fuse) -- [**Feather Icons**](https://github.com/feathericons/feather) -- [**Simple Icons**](https://github.com/simple-icons/simple-icons) -- **All Contributors and Supporters** +Features and changes: +- Table of Contents (ToC) floating on the side +- InstantClick integration +- Social icons from [Simple Icons](https://simpleicons.org/) +- Opinionated UI enhancements From 2023e862af062de8e3ff749be852d9ee4330c9a8 Mon Sep 17 00:00:00 2001 From: Reorx Date: Mon, 11 Apr 2022 18:18:07 +0800 Subject: [PATCH 14/15] always render SEO templates --- layouts/partials/head.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index b921452..35f6abd 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -147,7 +147,7 @@ {{- /* Misc */}} {{- if hugo.IsProduction | or (eq site.Params.env "production") }} {{- template "_internal/google_analytics.html" . }} +{{- end -}} {{- template "partials/templates/opengraph.html" . }} {{- template "partials/templates/twitter_cards.html" . }} {{- template "partials/templates/schema_json.html" . }} -{{- end -}} From 9678b1cb6fe7c999c673ba8261c00e7cce7a7533 Mon Sep 17 00:00:00 2001 From: Reorx Date: Mon, 11 Apr 2022 22:24:40 +0800 Subject: [PATCH 15/15] adjust head tags order put noscript at the end --- layouts/partials/head.html | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 35f6abd..99d33ae 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -102,6 +102,15 @@ {{ end -}} +{{- /* Misc */}} +{{- if hugo.IsProduction | or (eq site.Params.env "production") }} +{{- template "_internal/google_analytics.html" . }} +{{- end -}} +{{- template "partials/templates/opengraph.html" . }} +{{- template "partials/templates/twitter_cards.html" . }} +{{- template "partials/templates/schema_json.html" . }} + +{{- partial "extend_head.html" . }} - -{{- partial "extend_head.html" . -}} - -{{- /* Misc */}} -{{- if hugo.IsProduction | or (eq site.Params.env "production") }} -{{- template "_internal/google_analytics.html" . }} -{{- end -}} -{{- template "partials/templates/opengraph.html" . }} -{{- template "partials/templates/twitter_cards.html" . }} -{{- template "partials/templates/schema_json.html" . }}