diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | exampleSite/content/posts/readme.md | 11 | ||||
-rw-r--r-- | exampleSite/content/posts/syntax-highlighting-test.md | 8 | ||||
-rw-r--r-- | i18n/en.toml | 3 | ||||
-rw-r--r-- | i18n/pt.toml | 3 | ||||
-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 |
13 files changed, 103 insertions, 82 deletions
@@ -1,2 +1,3 @@ public -exampleSite/public
\ No newline at end of file +exampleSite/public +*.bak @@ -244,7 +244,7 @@ A **really** basic 404 page can be generated via config file by using: ### Custom partials * The site title can be replaced by creating a file named `layouts/partials/custom/site-title.html`; -* Custom favicons can be used by creating a file named `layouts/partials/custom/head.html`; +* Custom favicons can be used by creating a file named `layouts/partials/custom/head-append.html`; * Custom CSS can be imported into the main CSS file by creating a file named `static/css/custom.css` or `assets/scss/custom.scss`; * The `copyright` param can be replaced by creating a file named `layouts/partials/custom/copyright.html`. @@ -318,6 +318,8 @@ More possible params for your config file: [params.style] # Disable the use of system settings (prefers-color-scheme) + # Can be used as a workaround for Chrome on Linux + # (Issue 998903: Dark Gtk theme does not affect prefers-color-scheme media query) # The default is false ignoreSystemSettings = true @@ -357,4 +359,4 @@ More possible params for your config file: If this repo was useful or helpful to you in any way, please consider buying me a coffee: -<a href="https://www.buymeacoffee.com/rmaguiar" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/lato-orange.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;"></a> +<a href="https://www.buymeacoffee.com/rmaguiar" target="_blank" rel="noopener noreferrer"><img src="https://cdn.buymeacoffee.com/buttons/lato-orange.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;"></a> diff --git a/exampleSite/content/posts/readme.md b/exampleSite/content/posts/readme.md index 560ff16..2922bc9 100644 --- a/exampleSite/content/posts/readme.md +++ b/exampleSite/content/posts/readme.md @@ -1,6 +1,7 @@ --- -title: "Read Me" -description: "A copy of the README.md file." +title : "Read Me" +description : "A copy of the README.md file." +tags : [ extra, markdown ] --- [Live demo (on Netlify)](https://color-your-world-demo.netlify.app/) | [Demo (on Hugo Themes)](https://themes.gohugo.io/theme/hugo-theme-color-your-world/) @@ -247,7 +248,7 @@ A **really** basic 404 page can be generated via config file by using: ### Custom partials * The site title can be replaced by creating a file named `layouts/partials/custom/site-title.html`; -* Custom favicons can be used by creating a file named `layouts/partials/custom/head.html`; +* Custom favicons can be used by creating a file named `layouts/partials/custom/head-append.html`; * Custom CSS can be imported into the main CSS file by creating a file named `static/css/custom.css` or `assets/scss/custom.scss`; * The `copyright` param can be replaced by creating a file named `layouts/partials/custom/copyright.html`. @@ -321,6 +322,8 @@ More possible params for your config file: [params.style] # Disable the use of system settings (prefers-color-scheme) + # Can be used as a workaround for Chrome on Linux + # (Issue 998903: Dark Gtk theme does not affect prefers-color-scheme media query) # The default is false ignoreSystemSettings = true @@ -360,4 +363,4 @@ More possible params for your config file: If this repo was useful or helpful to you in any way, please consider buying me a coffee: -<a href="https://www.buymeacoffee.com/rmaguiar" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/lato-orange.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;"></a> +<a href="https://www.buymeacoffee.com/rmaguiar" target="_blank" rel="noopener noreferrer"><img src="https://cdn.buymeacoffee.com/buttons/lato-orange.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;"></a> diff --git a/exampleSite/content/posts/syntax-highlighting-test.md b/exampleSite/content/posts/syntax-highlighting-test.md index 54ba77f..eeadbb5 100644 --- a/exampleSite/content/posts/syntax-highlighting-test.md +++ b/exampleSite/content/posts/syntax-highlighting-test.md @@ -1,8 +1,8 @@ --- -title: "Syntax Highlighting Test" -description: "A page full of code samples." -tags: [ extra, "syntax highlighting" ] -toc: true +title : "Syntax Highlighting Test" +description : "A page full of code samples." +tags : [ extra, "syntax highlighting" ] +toc : true --- ## Bash diff --git a/i18n/en.toml b/i18n/en.toml index 6eded49..121b739 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -66,6 +66,9 @@ other = "Tag" [tags] other = "Tags" +[category] +other = "Category" + [categories] other = "Categories" diff --git a/i18n/pt.toml b/i18n/pt.toml index 9cd8b9c..fd11c6a 100644 --- a/i18n/pt.toml +++ b/i18n/pt.toml @@ -66,6 +66,9 @@ other = "Marcador" [tags] other = "Marcadores" +[category] +other = "Categoria" + [categories] other = "Categorias" 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 |