From a5b6827ebb202a0c7878026c7bcb2e72cc452dea Mon Sep 17 00:00:00 2001
From: Jan Heinrich Reimer
Date: Mon, 4 Mar 2024 12:57:45 +0100
Subject: [PATCH] Improve template readability
---
layouts/404.html | 4 ++--
layouts/robots.txt | 2 +-
layouts/shortcodes/cv/awards.gohtml | 4 ++--
layouts/shortcodes/cv/education.gohtml | 2 +-
layouts/shortcodes/cv/experience.gohtml | 2 +-
layouts/shortcodes/cv/facts.gohtml | 4 ++--
layouts/shortcodes/cv/highest-degree.gohtml | 2 +-
layouts/shortcodes/cv/open-source.gohtml | 8 ++++----
layouts/shortcodes/cv/publications.gohtml | 6 +++---
layouts/shortcodes/cv/skills.gohtml | 2 +-
layouts/shortcodes/github/repos.gohtml | 18 +++++++++---------
layouts/shortcodes/github/stats.gohtml | 12 ++++++------
layouts/shortcodes/github/tag.gohtml | 6 +++---
layouts/shortcodes/profile-image.gohtml | 9 +++------
layouts/shortcodes/sponsors.gohtml | 2 +-
15 files changed, 40 insertions(+), 43 deletions(-)
diff --git a/layouts/404.html b/layouts/404.html
index e3a5efca..6fac33de 100644
--- a/layouts/404.html
+++ b/layouts/404.html
@@ -8,9 +8,9 @@ {{- i18n "pageNotFound" -}}
{{- i18n "pageNotFoundAction" . -}}
- {{ i18n "homepage" }}
+ {{ i18n "homepage" }}
•
- {{ i18n "contact" }}
+ {{ i18n "contact" }}
{{ end }}
diff --git a/layouts/robots.txt b/layouts/robots.txt
index 33032686..6759cb83 100644
--- a/layouts/robots.txt
+++ b/layouts/robots.txt
@@ -1,6 +1,6 @@
User-agent: *
{{/* If ENV production variable is false robots will be disallowed. */}}
-{{ if eq $.Site.Params.env "production" }}
+{{ if eq site.Params.env "production" }}
Disallow:
{{ else }}
Disallow: /
diff --git a/layouts/shortcodes/cv/awards.gohtml b/layouts/shortcodes/cv/awards.gohtml
index cb224e73..69b2e5d9 100644
--- a/layouts/shortcodes/cv/awards.gohtml
+++ b/layouts/shortcodes/cv/awards.gohtml
@@ -1,4 +1,4 @@
-{{- $awards := $.Site.Data.awards -}}
+{{- $awards := site.Data.awards -}}
{{- $awards = sort $awards "month" "desc" -}}
{{- $awards = sort $awards "year" "desc" -}}
@@ -26,7 +26,7 @@
{{- end -}}
{{- with .value -}}
- {{- lang.NumFmt 0 .sum "- , ." -}} {{- .unit -}}
+ {{- lang.FormatNumberCustom 0 .sum "- , ." -}} {{- .unit -}}
{{- end -}}
{{- with .description -}}
diff --git a/layouts/shortcodes/cv/education.gohtml b/layouts/shortcodes/cv/education.gohtml
index b83b2783..312d3cbe 100644
--- a/layouts/shortcodes/cv/education.gohtml
+++ b/layouts/shortcodes/cv/education.gohtml
@@ -1,4 +1,4 @@
-{{- $education := $.Site.Data.education -}}
+{{- $education := site.Data.education -}}
{{- $education = sort $education "from.month" "desc" -}}
{{- $education = sort $education "from.year" "desc" -}}
diff --git a/layouts/shortcodes/cv/experience.gohtml b/layouts/shortcodes/cv/experience.gohtml
index 4bd52652..e8a27cf7 100644
--- a/layouts/shortcodes/cv/experience.gohtml
+++ b/layouts/shortcodes/cv/experience.gohtml
@@ -1,4 +1,4 @@
-{{- $experience := $.Site.Data.experience -}}
+{{- $experience := site.Data.experience -}}
diff --git a/layouts/shortcodes/cv/facts.gohtml b/layouts/shortcodes/cv/facts.gohtml
index aa965c9d..04d1c6ca 100644
--- a/layouts/shortcodes/cv/facts.gohtml
+++ b/layouts/shortcodes/cv/facts.gohtml
@@ -1,4 +1,4 @@
-{{- with $.Site.Data.facts -}}
+{{- with site.Data.facts -}}
@@ -17,7 +17,7 @@
{{- i18n "birthday" -}} |
- {{- time.Format ":date_long" .birthday -}} |
+ {{- dateFormat ":date_long" .birthday -}} |
{{- i18n "email" -}} |
diff --git a/layouts/shortcodes/cv/highest-degree.gohtml b/layouts/shortcodes/cv/highest-degree.gohtml
index 712f8050..2367f72c 100644
--- a/layouts/shortcodes/cv/highest-degree.gohtml
+++ b/layouts/shortcodes/cv/highest-degree.gohtml
@@ -1,4 +1,4 @@
-{{- with $.Site.Data.education -}}
+{{- with site.Data.education -}}
{{- $education := . -}}
{{- $education = where $education "to.year" ">" 0 -}}
{{- $education = sort $education "to.month" "desc" -}}
diff --git a/layouts/shortcodes/cv/open-source.gohtml b/layouts/shortcodes/cv/open-source.gohtml
index 621c5d6d..cd273042 100644
--- a/layouts/shortcodes/cv/open-source.gohtml
+++ b/layouts/shortcodes/cv/open-source.gohtml
@@ -1,5 +1,5 @@
-{{- $username := $.Site.Data.social.github -}}
-{{- with $.Site.Params.gitHubToken -}}
+{{- $username := site.Data.social.github -}}
+{{- with site.Params.gitHubToken -}}
{{- $username = print $username ":" . -}}
{{- end -}}
@@ -43,14 +43,14 @@ query {
{{- with resources.GetRemote "https://api.github.com/graphql" $pinnedReposOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
- {{- with .Content | transform.Unmarshal -}}
+ {{- with .Content | unmarshal -}}
{{- range .data.user.pinnedItems.nodes -}}
- {{- time.Format "01/2006" .createdAt -}}
+ {{- dateFormat "01/2006" .createdAt -}}
|
diff --git a/layouts/shortcodes/cv/publications.gohtml b/layouts/shortcodes/cv/publications.gohtml
index 0063ffbe..099d4f64 100644
--- a/layouts/shortcodes/cv/publications.gohtml
+++ b/layouts/shortcodes/cv/publications.gohtml
@@ -1,4 +1,4 @@
-{{- $author := $.Site.Data.facts.name -}}
+{{- $author := site.Data.facts.name -}}
{{- $webisPublicationsUrl := "https://webis.de/publications.html" -}}
@@ -20,7 +20,7 @@
{{- $xmlText = replace $xmlText " " " " -}}
{{- $xmlText = replace $xmlText "&" "&" -}}
{{- $xmlText = replace $xmlText "&" "&" -}}
- {{- $htmlEntities := resources.Get "csv/html-entities.csv" | transform.Unmarshal (dict "delimiter" ",") -}}
+ {{- $htmlEntities := resources.Get "csv/html-entities.csv" | unmarshal (dict "delimiter" ",") -}}
{{- range $htmlEntities -}}
{{- $htmlEntityGlyph := index . 0 -}}
{{- $htmlEntityName := index . 1 -}}
@@ -40,7 +40,7 @@
{{- $xmlResource := $xmlText | resources.FromString $xmlTargetPath -}}
{{/* Parse XML as map. */}}
- {{- with $xmlResource | transform.Unmarshal -}}
+ {{- with $xmlResource | unmarshal -}}
{{/* Navigate to publication list year entries. */}}
{{- $element := . -}}
{{- $element = index $element "body" -}}
diff --git a/layouts/shortcodes/cv/skills.gohtml b/layouts/shortcodes/cv/skills.gohtml
index 5de009fb..ce6e0681 100644
--- a/layouts/shortcodes/cv/skills.gohtml
+++ b/layouts/shortcodes/cv/skills.gohtml
@@ -1,4 +1,4 @@
-{{- with $.Site.Data.skills -}}
+{{- with site.Data.skills -}}
diff --git a/layouts/shortcodes/github/repos.gohtml b/layouts/shortcodes/github/repos.gohtml
index 563a8592..35ec6a41 100644
--- a/layouts/shortcodes/github/repos.gohtml
+++ b/layouts/shortcodes/github/repos.gohtml
@@ -1,5 +1,5 @@
-{{- $username := $.Site.Data.social.github -}}
-{{- with $.Site.Params.gitHubToken -}}
+{{- $username := site.Data.social.github -}}
+{{- with site.Params.gitHubToken -}}
{{- $username = print $username ":" . -}}
{{- end -}}
{{- if not $username -}}
@@ -43,7 +43,7 @@ query {
{{- $userUrl := "" -}}
{{- with resources.GetRemote "https://api.github.com/graphql" $userOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
- {{- with .Content | transform.Unmarshal -}}
+ {{- with .Content | unmarshal -}}
{{- $repositoriesCount = .data.user.repositories.totalCount -}}
{{- $userUrl = .data.user.url -}}
{{- else -}}
@@ -112,7 +112,7 @@ query {
{{- $reposCount := 0 -}}
{{- with resources.GetRemote "https://api.github.com/graphql" $reposOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
- {{- with .Content | transform.Unmarshal -}}
+ {{- with .Content | unmarshal -}}
{{- with .data.user.repositories.nodes -}}
{{- $repositories = append $repositories . -}}
{{- end -}}
@@ -216,8 +216,8 @@ query {
{{- $kilobytes := div $bytes 1000 -}}
{{- $megabytes := div $kilobytes 1000 -}}
- 📚 {{ .reposCount }}
- 💾 {{- $megabytes | lang.FormatNumber 2 -}} MB
+ 📚 {{ .reposCount }}
+ 💾 {{- $megabytes | lang.FormatNumber 2 -}} MB
@@ -241,7 +241,7 @@ query {
{{- $description -}}
- 📅 {{ time.Format ":date_short" .pushedAt }}
+ 📅 {{ dateFormat ":date_short" .pushedAt }}
⭐ {{ .stargazerCount }}
{{- end -}}
@@ -268,9 +268,9 @@ query {
{{- $moreRepos = sort $moreRepos "stargazers_count" "desc" -}}
{{/* Cut-off after top-3. */}}
{{- $moreRepos = first 3 $moreRepos -}}
-
+ |
{{- range $moreRepos -}}
- {{ .name }}
+ {{ .name }}
{{- end -}}
|
diff --git a/layouts/shortcodes/github/stats.gohtml b/layouts/shortcodes/github/stats.gohtml
index 86d3e877..9237470d 100644
--- a/layouts/shortcodes/github/stats.gohtml
+++ b/layouts/shortcodes/github/stats.gohtml
@@ -1,5 +1,5 @@
-{{- $username := $.Site.Data.social.github -}}
-{{- with $.Site.Params.gitHubToken -}}
+{{- $username := site.Data.social.github -}}
+{{- with site.Params.gitHubToken -}}
{{- $username = print $username ":" . -}}
{{- end -}}
{{- if not $username -}}
@@ -10,7 +10,7 @@
{{- $osiApprovedLicenses := slice -}}
{{- with resources.GetRemote "https://github.com/spdx/license-list-data/raw/main/json/licenses.json" -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
- {{- with .Content | transform.Unmarshal -}}
+ {{- with .Content | unmarshal -}}
{{- range (where .licenses "isOsiApproved" true) -}}
{{- $osiApprovedLicenses = append .licenseId $osiApprovedLicenses -}}
{{- end -}}
@@ -66,7 +66,7 @@ query {
{{- $organizationsCount := 0 -}}
{{- with resources.GetRemote "https://api.github.com/graphql" $userOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
- {{- with .Content | transform.Unmarshal -}}
+ {{- with .Content | unmarshal -}}
{{/* Count repos. */}}
{{- $repositoriesCount = .data.user.repositories.totalCount -}}
{{/* Count followers. */}}
@@ -124,7 +124,7 @@ query {
{{- $reposCount := 0 -}}
{{- with resources.GetRemote "https://api.github.com/graphql" $reposOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
- {{- with .Content | transform.Unmarshal -}}
+ {{- with .Content | unmarshal -}}
{{- with .data.user.repositories.nodes -}}
{{- $repositories = append $repositories . -}}
{{- end -}}
@@ -163,7 +163,7 @@ query {
{{- $contributionsOpts := dict "method" "post" "body" $contributionsBody "headers" $githubHeaders -}}
{{- with resources.GetRemote "https://api.github.com/graphql" $contributionsOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
- {{- with .Content | transform.Unmarshal -}}
+ {{- with .Content | unmarshal -}}
{{- with .data.user.contributionsCollection -}}
{{- $totalCommitContributions = add $totalCommitContributions .totalCommitContributions -}}
{{- $totalIssueContributions = add $totalIssueContributions .totalIssueContributions -}}
diff --git a/layouts/shortcodes/github/tag.gohtml b/layouts/shortcodes/github/tag.gohtml
index 1f82f508..4aacea5e 100644
--- a/layouts/shortcodes/github/tag.gohtml
+++ b/layouts/shortcodes/github/tag.gohtml
@@ -1,5 +1,5 @@
-{{- $username := $.Site.Data.social.github -}}
-{{- with $.Site.Params.gitHubToken -}}
+{{- $username := site.Data.social.github -}}
+{{- with site.Params.gitHubToken -}}
{{- $username = print $username ":" . -}}
{{- end -}}
{{- if not $username -}}
@@ -26,7 +26,7 @@ query {
{{- $userOpts := dict "method" "post" "body" $userBody "headers" $githubHeaders -}}
{{- with resources.GetRemote "https://api.github.com/graphql" $userOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
- {{- with .Content | transform.Unmarshal -}}
+ {{- with .Content | unmarshal -}}
@{{ .data.user.login }}
{{- else -}}
{{- errorf "Unable to parse GitHub GraphQL API response." -}}
diff --git a/layouts/shortcodes/profile-image.gohtml b/layouts/shortcodes/profile-image.gohtml
index 159a4723..d8e12723 100644
--- a/layouts/shortcodes/profile-image.gohtml
+++ b/layouts/shortcodes/profile-image.gohtml
@@ -1,11 +1,8 @@
-{{- $resource := resources.Get "profile.jpg" -}}
-{{- $title := i18n "profile" -}}
-{{- with $resource -}}
- {{- $link := $resource.RelPermalink -}}
+{{- with resources.Get "profile.jpg" -}}
diff --git a/layouts/shortcodes/sponsors.gohtml b/layouts/shortcodes/sponsors.gohtml
index 92f94d38..8ec70656 100644
--- a/layouts/shortcodes/sponsors.gohtml
+++ b/layouts/shortcodes/sponsors.gohtml
@@ -1,4 +1,4 @@
-{{ with $.Site.Data.sponsors }}
+{{ with site.Data.sponsors }}
|