diff options
author | Raphael Aguiar <rmaguiar@tuta.io> | 2020-08-19 20:59:40 +0300 |
---|---|---|
committer | Raphael Aguiar <rmaguiar@tuta.io> | 2020-08-19 20:59:40 +0300 |
commit | 07bcfd77b6a1e01ffd59c11295abb201f81c01c5 (patch) | |
tree | 15290a42ae9da6b0eb895b8f9e3ca24b185893a3 /layouts | |
parent | 15cd9c4c3d65a4c90f9c349fdabab7dd21cda1b5 (diff) |
Fix (hopefully) all issues related to taxonomies and minor changes
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/_markup/render-image.html | 8 | ||||
-rw-r--r-- | layouts/_default/list.html | 2 | ||||
-rw-r--r-- | layouts/partials/head-style.html | 38 | ||||
-rw-r--r-- | layouts/partials/head.html | 91 | ||||
-rw-r--r-- | layouts/partials/pagination.html | 2 | ||||
-rw-r--r-- | layouts/partials/post-list.html | 4 | ||||
-rw-r--r-- | layouts/shortcodes/abbr.html | 6 |
7 files changed, 80 insertions, 71 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index f264cde..2b6a519 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -53,14 +53,14 @@ Reduce reflow by creating a placeholder with similar size --> - {{ $placeholder := (.Resize (printf "%vx %s" .Width "png")) | images.Filter (images.Contrast -100) }} - {{ $encodedPlaceholder := (printf "data:image/png;base64,%s" ($placeholder.Content | base64Encode)) | safeURL }} + {{ $processed := (.Resize (printf "%vx" .Width)) }} + {{ $encodedPlaceholder := (printf "data:image/png;base64,%s" (((.Resize (printf "%vx %s" .Width "png")) | images.Filter (images.Contrast -100)).Content | base64Encode)) | safeURL }} <img class="lazyload {{ $class }}" loading="lazy" src="{{ $encodedPlaceholder }}" - data-src="{{ .RelPermalink }}" + data-src="{{ $processed.RelPermalink }}" {{ with $altText }}alt="{{ . }}"{{ end }} /> @@ -68,7 +68,7 @@ <img {{ with $class }}class="{{ . }}"{{ end }} loading="lazy" - src="{{ .RelPermalink }}" + src="{{ $processed.RelPermalink }}" {{ with $altText }}alt="{{ . }}"{{ end }} /> </noscript> diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 07d2c6a..09b42d9 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -14,7 +14,7 @@ <h1>{{ $currentTitle }}</h1> - {{ if eq .Kind "taxonomyTerm" }} + {{ if eq .Kind "taxonomy" }} {{ if eq .Type "categories" }} {{ partial "categories" . }} {{ else if eq .Type "tags" }} diff --git a/layouts/partials/head-style.html b/layouts/partials/head-style.html new file mode 100644 index 0000000..328ab31 --- /dev/null +++ b/layouts/partials/head-style.html @@ -0,0 +1,38 @@ +<!-- Main CSS --> +{{ $main := resources.Get "scss/main.scss" | resources.ExecuteAsTemplate "css/main.scss" . | toCSS | minify | resources.Fingerprint "sha512" }} +<link rel="stylesheet" href="{{ $main.RelPermalink }}" integrity="{{ $main.Data.Integrity }}"> + + +<!-- If JS is disabled --> +<noscript> + + {{ $darkAccent := .Site.Params.Style.darkAccent | default .Site.Data.default.style.darkAccent }} + {{ $lightAccent := .Site.Params.Style.lightAccent | default .Site.Data.default.style.lightAccent }} + + {{ if .Site.Params.Style.ignoreSystemSettings }} + + {{ if .Site.Params.Style.isDark }} + <meta name="theme-color" content="{{ $darkAccent }}"> + {{ else }} + <meta name="theme-color" content="{{ $lightAccent }}"> + {{ end }} + + {{ else }} + <meta name="theme-color" content="{{ $darkAccent }}" media="(prefers-color-scheme: dark)"> + <meta name="theme-color" content="{{ $lightAccent }}" media="(prefers-color-scheme: light)"> + {{ end }} + + <style> + + html { + --accent: {{ if .Site.Params.Style.isDark }}{{ $darkAccent }}{{ else }}{{ $lightAccent }}{{ end }}; + } + + .req-js, + img.lazyload { + display: none; + } + + </style> + +</noscript> diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 42e8e52..20eb603 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -16,35 +16,42 @@ {{ else if (eq .Kind "section") }} - <!-- If it's a post list --> + <!-- If post list --> {{ if gt .Paginator.TotalPages 1 }} {{ $mainTitle = printf "%s, %s %s %s %s" .Title (T "page") (string .Paginator.PageNumber) (T "of") (string .Paginator.TotalPages) }} {{ end }} -{{ else if (and (ne .Kind "taxonomyTerm") (eq .Type "tags")) }} +{{ else if eq .Kind "term" }} - <!-- If it's a post list for a tag --> - {{ $currentTitle = printf "%s: \"%s\"" (T "tag") .Title }} + {{ $currentTerm := "" }} - {{ if gt .Paginator.TotalPages 1 }} - {{ $mainTitle = printf "%s: \"%s\", %s %s %s %s" (T "tag") .Title (T "page") (string .Paginator.PageNumber) (T "of") (string .Paginator.TotalPages) }} + {{ if eq .Type "tags" }} + {{ $currentTerm = (T "tag") }} {{ else }} - {{ $mainTitle = printf "%s: \"%s\"" (T "tag") .Title }} + {{ $currentTerm = (T "category") }} + {{ end }} + + {{ $currentTitle = printf "%s: \"%s\"" $currentTerm .Title }} + + {{ with .Paginator }} + {{ if gt .TotalPages 1 }} + {{ $mainTitle = printf "%s: \"%s\", %s %s %s %s" $currentTerm $.Title (T "page") (string .PageNumber) (T "of") (string .TotalPages) }} + {{ else }} + {{ $mainTitle = printf "%s: \"%s\"" $currentTerm $.Title }} + {{ end }} {{ end }} -{{ else if (and (eq .Kind "taxonomyTerm") (eq .Type "tags")) }} - - <!-- /categories/ page --> - {{ $currentTitle = (T "tags") }} +{{ else if eq .Kind "taxonomy" }} -{{ else if (and (eq .Kind "taxonomyTerm") (eq .Type "categories")) }} + {{ if eq .Type "tags" }} + {{ $currentTitle = (T "tags") }} + {{ else }} + {{ $currentTitle = (T "categories") }} + {{ end }} - <!-- /tags/ page --> - {{ $currentTitle = (T "categories") }} - {{ else if and (.IsHome) (not .Content) }} - <!-- If it's the home page without content --> + <!-- If home page without content --> {{ $currentTitle = (.Site.Title | emojify) }} {{ end }} @@ -54,11 +61,11 @@ {{ if .IsHome }} {{ $currentDesc = (.Site.Params.description | emojify) }} -{{ else if and (ne .Kind "taxonomyTerm") (eq .Type "tags") (not .Params.description) }} +{{ else if and (ne .Kind "taxonomy") (eq .Type "tags") (not .Params.description) }} {{ $currentDesc = (T "postsUnderTag" .) }} -{{ else if and (ne .Kind "taxonomyTerm") (eq .Type "categories") (not .Params.description) }} +{{ else if and (ne .Kind "taxonomy") (eq .Type "categories") (not .Params.description) }} {{ $currentDesc = (T "postsUnderCategory" .) }} -{{ else if eq .Kind "taxonomyTerm" }} +{{ else if eq .Kind "taxonomy" }} {{ $currentDesc = printf "%s %s." (T "pageContaining") ($currentTitle | lower) }} {{ else if (eq .Kind "404") }} {{ $currentDesc = .Site.Params.notFound.description | default .Site.Data.default.notFound.description }} @@ -117,9 +124,9 @@ {{ end }} -<!-- Reserved --> -{{ if or (templates.Exists "partials/custom/head") (templates.Exists "partials/custom/head.html") }} - {{ partial "custom/head" . }} +<!-- If the user wants to add something (custom favicons, fonts, scripts, etc) --> +{{ if or (templates.Exists "partials/custom/head-append") (templates.Exists "partials/custom/head-append.html") }} + {{ partial "custom/head-append" . }} {{ end }} @@ -324,44 +331,8 @@ {{ end }} -<!-- Main CSS --> -{{ $main := resources.Get "scss/main.scss" | resources.ExecuteAsTemplate "css/main.scss" . | toCSS | minify | resources.Fingerprint "sha512" }} -<link rel="stylesheet" href="{{ $main.RelPermalink }}" integrity="{{ $main.Data.Integrity }}"> - - -<!-- If JS is disabled --> -<noscript> - - {{ $darkAccent := .Site.Params.Style.darkAccent | default .Site.Data.default.style.darkAccent }} - {{ $lightAccent := .Site.Params.Style.lightAccent | default .Site.Data.default.style.lightAccent }} - - {{ if .Site.Params.Style.ignoreSystemSettings }} - - {{ if .Site.Params.Style.isDark }} - <meta name="theme-color" content="{{ $darkAccent }}"> - {{ else }} - <meta name="theme-color" content="{{ $lightAccent }}"> - {{ end }} - - {{ else }} - <meta name="theme-color" content="{{ $darkAccent }}" media="(prefers-color-scheme: dark)"> - <meta name="theme-color" content="{{ $lightAccent }}" media="(prefers-color-scheme: light)"> - {{ end }} - - <style> - - html { - --accent: {{ if .Site.Params.Style.isDark }}{{ $darkAccent }}{{ else }}{{ $lightAccent }}{{ end }}; - } - - .req-js, - img.lazyload { - display: none; - } - - </style> -</noscript> - +<!-- Cached style --> +{{ partialCached "head-style" . }} <!-- Preload fonts --> {{ partialCached "font-preload" . }} diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html index bf9dde4..51500df 100644 --- a/layouts/partials/pagination.html +++ b/layouts/partials/pagination.html @@ -1,4 +1,4 @@ -{{ $pag := $.Paginator }} +{{ $pag := .Paginator }} <!-- Number of links either side of the current page. Default value is 2 --> diff --git a/layouts/partials/post-list.html b/layouts/partials/post-list.html index 732bc9c..0c9b8fe 100644 --- a/layouts/partials/post-list.html +++ b/layouts/partials/post-list.html @@ -1,7 +1,7 @@ -{{ $paginator := .Paginate (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) }}
+{{ $pag := .Paginate (where .RegularPages "Type" "in" .Site.Params.mainSections) }}
<ul class="posts">
- {{ range $paginator.Pages }}
+ {{ range $pag.Pages }}
{{ $pageDate := "" }}
diff --git a/layouts/shortcodes/abbr.html b/layouts/shortcodes/abbr.html index 7884531..82d9bc3 100644 --- a/layouts/shortcodes/abbr.html +++ b/layouts/shortcodes/abbr.html @@ -2,7 +2,7 @@ abbr "idk" "I don't know" --> -{{ $abbr := (.Get 0) }} -{{ $title := (.Get 1) }} +{{- $abbr := (.Get 0) -}} +{{- $title := (.Get 1) -}} -<abbr title="{{ $title }}">{{ $abbr }}</abbr> +<abbr title="{{ $title }}">{{ $abbr }}</abbr>
\ No newline at end of file |