From 6d842eefd0831c89f3be60e85dba91304fd3d00d Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 24 Jul 2022 13:05:46 +0200 Subject: Provide 'Back to top' functionality --- layouts/_default/baseof.html | 12 +++++++++++- layouts/partials/head.html | 3 ++- layouts/partials/scripts.html | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 layouts/partials/scripts.html (limited to 'layouts') diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 4985ca3..5f095c2 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,7 +1,8 @@ - + {{ partial "head.html" . }} +
{{ if .Params.toc }} {{ partial "sidebar-toc.html" . }} {{ else }} @@ -23,5 +24,14 @@ + + + + {{ i18n "back_to_top" }} + + + + + diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 934ccc9..036b26d 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -35,6 +35,7 @@ {{- template "partials/templates/twitter_cards.html" . }} {{- template "partials/templates/schema_json.html" . }} - {{- /* SEO */}} + {{- /* Scripts */}} + {{- partial "partials/scripts.html" . }} {{- partial "partials/seo/ga.html" . }} diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html new file mode 100644 index 0000000..a42e492 --- /dev/null +++ b/layouts/partials/scripts.html @@ -0,0 +1,14 @@ +{{- $isProduction := (or (eq (getenv "HUGO_ENV") "production") (eq site.Params.env "production")) -}} + +{{- $scripts := slice -}} +{{- $scripts = $scripts | append (resources.Get "js/ed.js") -}} +{{- $scripts = $scripts | resources.Concat "js/common.js" -}} + +{{- $scripts = $scripts | js.Build (dict "format" "iife" "minify" $isProduction) -}} + +{{- if or (site.Params.assets.disable_fingerprinting) (not $isProduction) }} + +{{- else -}} + {{- $scripts = $scripts | fingerprint }} + +{{- end -}} -- cgit v1.2.3