From 86416cbe2731a5289659200532f4707e5318899c Mon Sep 17 00:00:00 2001 From: Wen Junhua Date: Tue, 30 Apr 2024 23:07:58 +0800 Subject: [PATCH] fix: update to also obey site settings --- assets/js/appearance.js | 27 +++++++++++++++++---------- layouts/_default/baseof.html | 6 ++++-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/assets/js/appearance.js b/assets/js/appearance.js index 2f01c4ff5..0cdfd1565 100644 --- a/assets/js/appearance.js +++ b/assets/js/appearance.js @@ -39,17 +39,24 @@ if (document.documentElement.getAttribute("data-auto-appearance") === "true") { } function add_to_top_elem() { - var body = document.body, - html = document.documentElement; + var body = document.body; + var html = document.documentElement; - const height = Math.max( - body.scrollHeight, - body.offsetHeight, - html.clientHeight, - html.scrollHeight, - html.offsetHeight - ) - 150; - document.getElementById("to-top").hidden = height < window.innerHeight; + const height = + Math.max( + body.scrollHeight, + body.offsetHeight, + html.clientHeight, + html.scrollHeight, + html.offsetHeight + ) - 150; + + const elem = document.getElementById("to-top"); + if (elem === null || elem === undefined) { + return; + } + + elem.hidden = height < window.innerHeight; } window.addEventListener("DOMContentLoaded", (event) => { diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 02a89bd74..28c8daf91 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -29,10 +29,12 @@
{{ block "main" . }}{{ end }} +
+ {{ if .Site.Params.footer.showScrollToTop | default true }} - + {{ end }} {{- partial "footer.html" . -}} {{ if .Site.Params.enableSearch | default false }} {{- partial "search.html" . -}}