diff options
author | Raphael Aguiar <rmaguiar@tuta.io> | 2020-06-26 19:58:11 +0300 |
---|---|---|
committer | Raphael Aguiar <rmaguiar@tuta.io> | 2020-06-26 20:05:22 +0300 |
commit | fe6d519f8e5f5267aa6de12930cb75fba0ddbaa6 (patch) | |
tree | 3e1cb3831fc250b8b61300e5859d8e1fe0107de8 /layouts | |
parent | b69561eeb3775b14bb04f61bc69c89cd40bc0f25 (diff) |
Add default accent colors and update use of Scratch
* Add default accent colors, because the user shouldn't be obliged to
set these params to see the theme working as intended
* Update use of Scratch. Some scopes were unnecessary and there were
also some repetitions
* Minor change to the JS. Add KaTeX-related JS to the KaTeX partial
* Update color-picker.png to reflect the accent color changes
* Remove some outdated comments
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/_markup/render-heading.html | 4 | ||||
-rw-r--r-- | layouts/_default/baseof.html | 2 | ||||
-rw-r--r-- | layouts/_default/list.html | 6 | ||||
-rw-r--r-- | layouts/_default/single.html | 4 | ||||
-rw-r--r-- | layouts/partials/footer.html | 10 | ||||
-rw-r--r-- | layouts/partials/head.html | 17 | ||||
-rw-r--r-- | layouts/partials/katex.html | 5 | ||||
-rw-r--r-- | layouts/shortcodes/social.html | 45 |
8 files changed, 53 insertions, 40 deletions
diff --git a/layouts/_default/_markup/render-heading.html b/layouts/_default/_markup/render-heading.html index 85e04c9..78f73ea 100644 --- a/layouts/_default/_markup/render-heading.html +++ b/layouts/_default/_markup/render-heading.html @@ -7,12 +7,12 @@ Would like to test a few more things --> -{{ $svgBundle := ($.Page.Scratch.Get "svgBundle").RelPermalink }} +{{ $icons := (.Page.Scratch.Get "svgBundle").RelPermalink }} {{ $anchoredLinkLevels := slice 2 3 }} {{ if in $anchoredLinkLevels .Level }} - <h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }} {{ printf "<a class=\"anchor\" href=\"#%s\" title='%s \"%s\".'><svg aria-hidden=\"true\"><use xlink:href=\"%s#hashtag\"/></svg></a>" (.Anchor | safeURL) (T "anchor_for") (.Text | plainify | safeHTML) $svgBundle | safeHTML }}</h{{ .Level }}> + <h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }} {{ printf "<a class=\"anchor\" href=\"#%s\" title='%s \"%s\".'><svg aria-hidden=\"true\"><use xlink:href=\"%s#hashtag\"/></svg></a>" (.Anchor | safeURL) (T "anchor_for") (.Text | plainify | safeHTML) $icons | safeHTML }}</h{{ .Level }}> {{ else }} <h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }}</h{{ .Level }}> {{ end }} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 74f0a26..fab044a 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -4,7 +4,7 @@ --> {{- $svgBundle := resources.Get "bundle.svg" | resources.ExecuteAsTemplate "img/bundle.svg" . | minify | resources.Fingerprint "md5" -}} -{{- $.Page.Scratch.Set "svgBundle" $svgBundle -}} +{{- .Scratch.Set "svgBundle" $svgBundle -}} <!DOCTYPE html> <html lang="{{ .Site.Language.Lang }}" data-mode="{{ if .Site.Params.Style.isDark }}dark{{ else }}light{{ end }}"> diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 1ea0aa3..6d86f16 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -14,12 +14,6 @@ {{ end }} {{ else }} - <!-- - range last 9 - .Format "2006-01-02" - | dateFormat "Jan 02" - --> - {{ $pages := where site.RegularPages "Type" "in" .Site.Params.mainSections }} {{ $paginator := .Paginate .Pages }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 33dd41e..2a5ebe9 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,6 +1,6 @@ {{ define "main" }} - {{ $svgBundle := ($.Page.Scratch.Get "svgBundle").RelPermalink }} + {{ $icons := (.Scratch.Get "svgBundle").RelPermalink }} <main> <article> @@ -74,7 +74,7 @@ <!-- OR replace the footnote return links with a SVG icon --> {{ if .Site.Params.Style.hasIconAsFootnoteReturnLink }} - {{ $footnoteReturnLink = ( printf "${1}<svg transform=\"rotate(180) translate(0 -1)\" aria-hidden=\"true\" ><use xlink:href=\"%s#caret-down\"/></svg>${2}" $svgBundle) }} + {{ $footnoteReturnLink = ( printf "${1}<svg transform=\"rotate(180) translate(0 -1)\" aria-hidden=\"true\" ><use xlink:href=\"%s#caret-down\"/></svg>${2}" $icons) }} {{ end }} <!-- diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 6462b80..489f363 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,6 +1,10 @@ -<!-- Set SVG bundle --> +<!-- Get SVG bundle --> {{ $icons := (.Scratch.Get "svgBundle").RelPermalink }} +<!-- Get default accent colors --> +{{ $darkAccent := .Scratch.Get "darkAccent" }} +{{ $lightAccent := .Scratch.Get "lightAccent" }} + <!-- Custom footer or default copyright --> {{ if or (templates.Exists "partials/custom/footer") (templates.Exists "partials/custom/footer.html") }} {{ partialCached "custom/footer" . }} @@ -27,9 +31,9 @@ {{ end }} -<!-- Fancy stuff --> +<!-- Footer button and color picker --> <aside class="js"> - <button title="{{ T "change_mode" }}"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><use xlink:href="{{ $icons }}#adjust"/></svg></button><input type="color" list="presets" value="{{ if .Site.Params.Style.isDark }}{{ .Site.Params.style.darkAccent }}{{ else }}{{ .Site.Params.style.lightAccent }}{{ end }}" title="{{ T "change_accent" }}"><datalist id="presets"><option value="{{ .Site.Params.style.lightAccent }}"><option value="{{ .Site.Params.style.darkAccent }}"><!-- Extra colors -->{{- range .Site.Params.style.presets -}}<option value="{{ . }}">{{ end }}</datalist> + <button title="{{ T "change_mode" }}"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><use xlink:href="{{ $icons }}#adjust"/></svg></button><input type="color" list="presets" value="{{ if .Site.Params.Style.isDark }}{{ $darkAccent }}{{ else }}{{ $lightAccent }}{{ end }}" title="{{ T "change_accent" }}"><datalist id="presets"><option value="{{ $lightAccent }}"><option value="{{ $darkAccent }}"><!-- Extra colors -->{{- range .Site.Params.style.presets -}}<option value="{{ . }}">{{ end }}</datalist> </aside> <!-- noscript notice --> diff --git a/layouts/partials/head.html b/layouts/partials/head.html index fe89a10..f04f4e7 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -299,6 +299,10 @@ {{ end }} +<!-- Set as scratch to be used in CSS and JS --> +{{ $changeTransition := .Site.Params.Style.changeTransition | default ".5s ease" }} +{{ .Scratch.Set "changeTransition" $changeTransition }} + <!-- Main CSS --> {{ $main := resources.Get "scss/main.scss" | resources.ExecuteAsTemplate "css/main.scss" . | toCSS | minify | resources.Fingerprint "sha512" }} @@ -308,14 +312,21 @@ <!-- If JS is disabled --> <noscript> + {{ $darkAccent := .Site.Params.Style.darkAccent | default "#dd587c" }} + {{ $lightAccent := .Site.Params.Style.lightAccent | default "#225670" }} + + <!-- Set default accent colors --> + {{ .Scratch.Set "darkAccent" $darkAccent }} + {{ .Scratch.Set "lightAccent" $lightAccent }} + <!-- Not properly tested? --> - <meta name="theme-color" content="{{ .Site.Params.Style.lightAccent }}" {{ if .Site.Params.Style.isDark }}media="(prefers-color-scheme: light)"{{ end }}> - <meta name="theme-color" content="{{ .Site.Params.Style.darkAccent }}" {{ if not .Site.Params.Style.isDark }}media="(prefers-color-scheme: dark)"{{ end }}> + <meta name="theme-color" content="{{ $darkAccent }}" {{ if not .Site.Params.Style.isDark }}media="(prefers-color-scheme: dark)"{{ end }}> + <meta name="theme-color" content="{{ $lightAccent }}" {{ if .Site.Params.Style.isDark }}media="(prefers-color-scheme: light)"{{ end }}> <style> html { - --accent: {{ if .Site.Params.Style.isDark }}{{ .Site.Params.Style.darkAccent }}{{ else }}{{ .Site.Params.Style.lightAccent }}{{ end }}; + --accent: {{ if .Site.Params.Style.isDark }}{{ $darkAccent }}{{ else }}{{ $lightAccent }}{{ end }}; } .js, diff --git a/layouts/partials/katex.html b/layouts/partials/katex.html index 64b9a37..bb664af 100644 --- a/layouts/partials/katex.html +++ b/layouts/partials/katex.html @@ -26,6 +26,11 @@ -->
<script>
+ 'use strict';
+
+ function getAll(selector) {
+ return Array.prototype.slice.call(document.querySelectorAll(selector), 0)
+ };
function addTabIndex() {
diff --git a/layouts/shortcodes/social.html b/layouts/shortcodes/social.html index a27a962..2740069 100644 --- a/layouts/shortcodes/social.html +++ b/layouts/shortcodes/social.html @@ -1,9 +1,14 @@ -{{ $svgBundle := resources.Get "bundle.svg" | resources.ExecuteAsTemplate "img/bundle.svg" . | minify | resources.Fingerprint "md5" }} -{{ $icons := $svgBundle.RelPermalink }} +{{ $icons := (.Page.Scratch.Get "svgBundle").RelPermalink }} + +<!-- Reduce repetition... --> +{{ $centralizedOnPage := .Page.Params.Social.Centralized }} +{{ $centralizedOnSite := .Site.Params.Social.Centralized }} +{{ $decentralizedOnPage := .Page.Params.Social.Decentralized }} +{{ $decentralizedOnSite := .Site.Params.Social.Decentralized }} <section class="social"> - {{ with or .Page.Params.Social.Centralized.facebook .Site.Params.Social.Centralized.facebook }} + {{ with or $centralizedOnPage.facebook $centralizedOnSite.facebook }} {{ $url := (index . 0) }} {{ $label := "Facebook" }} @@ -22,7 +27,7 @@ {{ end }} - {{ with or .Page.Params.Social.Centralized.github .Site.Params.Social.Centralized.github }} + {{ with or $centralizedOnPage.github $centralizedOnSite.github }} {{ $url := (index . 0) }} {{ $label := "GitHub" }} @@ -41,7 +46,7 @@ {{ end }} - {{ with or .Page.Params.Social.Centralized.gitlab .Site.Params.Social.Centralized.gitlab }} + {{ with or $centralizedOnPage.gitlab $centralizedOnSite.gitlab }} {{ $url := (index . 0) }} {{ $label := "GitLab" }} @@ -60,7 +65,7 @@ {{ end }} - {{ with or .Page.Params.Social.Centralized.instagram .Site.Params.Social.Centralized.instagram }} + {{ with or $centralizedOnPage.instagram $centralizedOnSite.instagram }} {{ $url := (index . 0) }} {{ $label := "Instagram" }} @@ -79,7 +84,7 @@ {{ end }} - {{ with or .Page.Params.Social.Centralized.keybase .Site.Params.Social.Centralized.keybase }} + {{ with or $centralizedOnPage.keybase $centralizedOnSite.keybase }} {{ $url := (index . 0) }} {{ $label := "Keybase" }} @@ -98,7 +103,7 @@ {{ end }} - {{ with or .Page.Params.Social.Centralized.linkedin .Site.Params.Social.Centralized.linkedin }} + {{ with or $centralizedOnPage.linkedin $centralizedOnSite.linkedin }} {{ $url := (index . 0) }} {{ $label := "LinkedIn" }} @@ -119,15 +124,9 @@ + {{ if or $decentralizedOnPage.mastodon $decentralizedOnSite.mastodon }} - - - - - - {{ if or .Page.Params.Social.Decentralized.mastodon .Site.Params.Social.Decentralized.mastodon }} - - {{ range or .Page.Params.Social.Decentralized.mastodon .Site.Params.Social.Decentralized.mastodon }} + {{ range or $decentralizedOnPage.mastodon $decentralizedOnSite.mastodon }} <a rel="me nofollow" href="{{ index . 0 }}" title="{{ index . 1 }} (Mastodon)"> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true"> @@ -141,9 +140,9 @@ {{ end }} - {{ if or .Page.Params.Social.Decentralized.matrix .Site.Params.Social.Decentralized.matrix }} + {{ if or $decentralizedOnPage.matrix $decentralizedOnSite.matrix }} - {{ range or .Page.Params.Social.Decentralized.matrix .Site.Params.Social.Decentralized.matrix }} + {{ range or $decentralizedOnPage.matrix $decentralizedOnSite.matrix }} <a rel="me nofollow" href="{{ index . 0 }}" title="{{ index . 1 }} (Matrix)"> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true"> <use xlink:href="{{ $icons }}#matrix"/> @@ -156,7 +155,7 @@ {{ end }} - {{ with or .Page.Params.Social.Centralized.medium .Site.Params.Social.Centralized.medium }} + {{ with or $centralizedOnPage.medium $centralizedOnSite.medium }} {{ $url := (index . 0) }} {{ $label := "Medium" }} @@ -176,7 +175,7 @@ {{ end }} - {{ with or .Page.Params.Social.Centralized.stackOverflow .Site.Params.Social.Centralized.stackOverflow }} + {{ with or $centralizedOnPage.stackOverflow $centralizedOnSite.stackOverflow }} {{ $url := (index . 0) }} {{ $label := "Stack Overflow" }} @@ -196,7 +195,7 @@ {{ end }} - {{ with or .Page.Params.Social.Centralized.reddit .Site.Params.Social.Centralized.reddit }} + {{ with or $centralizedOnPage.reddit $centralizedOnSite.reddit }} {{ $url := (index . 0) }} {{ $label := "Reddit" }} @@ -216,7 +215,7 @@ {{ end }} - {{ with or .Page.Params.Social.Centralized.telegram .Site.Params.Social.Centralized.telegram }} + {{ with or $centralizedOnPage.telegram $centralizedOnSite.telegram }} {{ $url := (index . 0) }} {{ $label := "Telegram" }} @@ -235,7 +234,7 @@ {{ end }} - {{ with or .Page.Params.Social.Centralized.twitter .Site.Params.Social.Centralized.twitter }} + {{ with or $centralizedOnPage.twitter $centralizedOnSite.twitter }} {{ $url := (index . 0) }} {{ $label := "Twitter" }} |