From ae477ab224489c9a5ff56705da5f84296ca82bb1 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Fri, 1 Jan 2021 13:04:37 +0100 Subject: [PATCH 1/9] refactor(archives): remove archive.categories i18n item (#108) It's possible in the future to display another kind of taxonomy. To translate that title, create _index.md under content/categories, with the following content: --- title: Category --- --- i18n/en.yaml | 4 ---- i18n/ja.yaml | 4 ---- i18n/pt-BR.yaml | 4 ---- i18n/ru.yaml | 4 ---- i18n/tr.yaml | 4 ---- i18n/zh-CN.yaml | 4 ---- layouts/_default/archives.html | 9 +++++---- 7 files changed, 5 insertions(+), 28 deletions(-) diff --git a/i18n/en.yaml b/i18n/en.yaml index e131b61..99d34ce 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -16,10 +16,6 @@ list: one: Subsection other: Subsections -archives: - categories: - other: Categories - article: relatedContents: other: Related contents diff --git a/i18n/ja.yaml b/i18n/ja.yaml index e83e531..e9744c2 100644 --- a/i18n/ja.yaml +++ b/i18n/ja.yaml @@ -4,10 +4,6 @@ toggleMenu: darkMode: other: ダークモード -archives: - categories: - other: 分類 - article: relatedContents: other: 関連するコンテンツ diff --git a/i18n/pt-BR.yaml b/i18n/pt-BR.yaml index 5380c68..33f14f8 100644 --- a/i18n/pt-BR.yaml +++ b/i18n/pt-BR.yaml @@ -1,10 +1,6 @@ toggleMenu: other: Alternar Menu -archives: - categories: - other: Categorias - article: relatedContents: other: Conteúdos Relacionados diff --git a/i18n/ru.yaml b/i18n/ru.yaml index f606ffa..284c45c 100644 --- a/i18n/ru.yaml +++ b/i18n/ru.yaml @@ -20,10 +20,6 @@ list: many: Подразделов other: Подразделов -archives: - categories: - other: Категории - article: relatedContents: other: Также рекомендуем diff --git a/i18n/tr.yaml b/i18n/tr.yaml index fbcb7b0..fe9269b 100644 --- a/i18n/tr.yaml +++ b/i18n/tr.yaml @@ -16,10 +16,6 @@ list: one: Alt bölüm other: Alt bölümler -archives: - categories: - other: Kategoriler - article: relatedContents: other: Alakalı içerikler diff --git a/i18n/zh-CN.yaml b/i18n/zh-CN.yaml index 0583bf7..9f1ac94 100644 --- a/i18n/zh-CN.yaml +++ b/i18n/zh-CN.yaml @@ -4,10 +4,6 @@ toggleMenu: darkMode: other: 暗色模式 -archives: - categories: - other: 分类 - article: relatedContents: other: 相关文章 diff --git a/layouts/_default/archives.html b/layouts/_default/archives.html index 49c0ddf..321aa6d 100644 --- a/layouts/_default/archives.html +++ b/layouts/_default/archives.html @@ -1,11 +1,12 @@ {{ define "body-class" }}template-archives{{ end }} {{ define "main" }} - {{ $categories := ($.Site.GetPage "taxonomyTerm" "categories").Pages }} - {{ if $categories }} -

{{ T "archives.categories" }}

+ {{- $taxonomy := $.Site.GetPage "taxonomyTerm" "categories" -}} + {{- $terms := $taxonomy.Pages -}} + {{ if $terms }} +

{{ $taxonomy.Title }}

- {{ range $categories }} + {{ range $terms }} {{ partial "article-list/tile" (dict "context" . "size" "250x150" "Type" "taxonomy") }} {{ end }}
From 5ac2552e7c5f8cff0bf0f34c9cbc42bf8d344f45 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Fri, 1 Jan 2021 13:12:23 +0100 Subject: [PATCH 2/9] fix(widget/search): remove hardcoded form action --- layouts/partials/widget/search.html | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/layouts/partials/widget/search.html b/layouts/partials/widget/search.html index 2275eb9..833f740 100644 --- a/layouts/partials/widget/search.html +++ b/layouts/partials/widget/search.html @@ -1,10 +1,16 @@ -
-

- - - - -

-
\ No newline at end of file +{{- $query := first 1 (where .Site.Pages "Layout" "==" "search") -}} +{{- if $query -}} + {{- $searchPage := index $query 0 -}} +
+

+ + + + +

+
+{{- else -}} + {{- warnf "Search page not found. Create a page with layout: search." -}} +{{- end -}} \ No newline at end of file From efa3452cdbabe25984aea87472fb135ec0fd755e Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Fri, 1 Jan 2021 13:16:11 +0100 Subject: [PATCH 3/9] refactor(widget/archives): remove .widgets.archives.path config The theme will automatically detect the permalink to the archives page. --- exampleSite/config.yaml | 3 +- layouts/partials/widget/archives.html | 58 +++++++++++++++------------ 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index a0266c8..fb89f51 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -60,7 +60,6 @@ params: archives: limit: 5 - path: archives tagCloud: limit: 10 @@ -82,7 +81,7 @@ params: colorScheme: # Display toggle toggle: true - + # Available values: auto, light, dark default: auto diff --git a/layouts/partials/widget/archives.html b/layouts/partials/widget/archives.html index 950dbf2..4a92a30 100644 --- a/layouts/partials/widget/archives.html +++ b/layouts/partials/widget/archives.html @@ -1,27 +1,33 @@ -
-
- {{ partial "helper/icon" "infinity" }} -
-

{{ T "widget.archives.title" }}

+{{- $query := first 1 (where .Site.Pages "Layout" "==" "archives") -}} +{{- if $query -}} + {{- $archivesPage := index $query 0 -}} +
+
+ {{ partial "helper/icon" "infinity" }} +
+

{{ T "widget.archives.title" }}

- {{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} - {{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }} - {{ $filtered := ($pages | intersect $notHidden) }} - {{ $archives := $filtered.GroupByDate "2006" }} - -
- {{ range $index, $item := first (add .Site.Params.widgets.archives.limit 1) ($archives) }} - {{- $id := lower (replace $item.Key " " "-") -}} - - {{ end }} -
-
\ No newline at end of file + {{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} + {{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }} + {{ $filtered := ($pages | intersect $notHidden) }} + {{ $archives := $filtered.GroupByDate "2006" }} + +
+ {{ range $index, $item := first (add .Site.Params.widgets.archives.limit 1) ($archives) }} + {{- $id := lower (replace $item.Key " " "-") -}} + + {{ end }} +
+
+{{- else -}} + {{- warnf "Archives page not found. Create a page with layout: archives." -}} +{{- end -}} \ No newline at end of file From 2ee854dd6af3c2915c94302e0d25574f1b8e9684 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Fri, 1 Jan 2021 13:24:26 +0100 Subject: [PATCH 4/9] fix(search): add missing i18n text (#110) --- layouts/page/search.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/page/search.html b/layouts/page/search.html index 259d398..935b384 100644 --- a/layouts/page/search.html +++ b/layouts/page/search.html @@ -11,7 +11,7 @@

- From 84dd80959a0cd6183cff5c8437e84e6f6a9abd07 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Fri, 1 Jan 2021 13:32:19 +0100 Subject: [PATCH 5/9] fix: make Disqus / Utterances follow the global color scheme (#111) * fix: make Disqus / Utterances follow the global color scheme * fix: check if DISQUS exists before executing DISQUS.reset closes https://github.com/CaiJimmy/hugo-theme-stack/issues/107 --- layouts/partials/comments/provider/disqus.html | 10 ++++++++++ .../partials/comments/provider/utterances.html | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/layouts/partials/comments/provider/disqus.html b/layouts/partials/comments/provider/disqus.html index 74f3460..1f283df 100644 --- a/layouts/partials/comments/provider/disqus.html +++ b/layouts/partials/comments/provider/disqus.html @@ -10,3 +10,13 @@ padding: var(--card-padding); } + + \ No newline at end of file diff --git a/layouts/partials/comments/provider/utterances.html b/layouts/partials/comments/provider/utterances.html index 75d63ce..e2ecf6d 100644 --- a/layouts/partials/comments/provider/utterances.html +++ b/layouts/partials/comments/provider/utterances.html @@ -13,4 +13,19 @@ .utterances { max-width: unset; } - \ No newline at end of file + + + \ No newline at end of file From 0de250c9ffa411191b0a0d8520d76d99e11f496a Mon Sep 17 00:00:00 2001 From: Daniel Pessoa Date: Sat, 2 Jan 2021 06:52:20 -0300 Subject: [PATCH 6/9] feat(i18n): Improve Brazilian portuguese translation (#112) --- i18n/pt-BR.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/i18n/pt-BR.yaml b/i18n/pt-BR.yaml index 33f14f8..8240755 100644 --- a/i18n/pt-BR.yaml +++ b/i18n/pt-BR.yaml @@ -1,6 +1,21 @@ toggleMenu: other: Alternar Menu +darkMode: + other: Modo Escuro + +list: + page: + one: "{{ .Count }} página" + other: "{{ .Count }} páginas" + + section: + other: Seção + + subsection: + one: Subseção + other: Subseções + article: relatedContents: other: Conteúdos Relacionados From 1ec73b2d761826cb5d73e4ddbf9f80dffc0d6178 Mon Sep 17 00:00:00 2001 From: SOT-TECH <41361221+sot-tech@users.noreply.github.com> Date: Mon, 4 Jan 2021 00:42:08 +0300 Subject: [PATCH 7/9] fix(i18n/ru): fix typo in 'notFound' (#114) --- i18n/ru.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/i18n/ru.yaml b/i18n/ru.yaml index 284c45c..f0c562f 100644 --- a/i18n/ru.yaml +++ b/i18n/ru.yaml @@ -12,13 +12,13 @@ list: other: "{{ .Count }} страниц" section: - other: Разделы + other: Раздел subsection: one: Подраздел - few: Подраздела - many: Подразделов - other: Подразделов + few: Подразделы + many: Подразделы + other: Подразделы article: relatedContents: @@ -28,7 +28,7 @@ article: notFound: title: - other: Не найшено + other: Не найдено subtitle: other: Запрашиваемая страница не существует @@ -54,4 +54,4 @@ footer: builtWith: other: Создано при помощи {{ .Generator }} designedBy: - other: Тема {{ .Theme }} дизайн {{ .DesignedBy }} + other: Тема {{ .Theme }}, дизайн {{ .DesignedBy }} From 90e259f31e7a06a36e66ea1a6a473aeaea01d95f Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Mon, 4 Jan 2021 10:52:14 +0100 Subject: [PATCH 8/9] fix(colorScheme): dispatch onColorSchemeChange at page load (#118) --- assets/ts/colorScheme.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assets/ts/colorScheme.ts b/assets/ts/colorScheme.ts index e17ff07..7c4ff77 100644 --- a/assets/ts/colorScheme.ts +++ b/assets/ts/colorScheme.ts @@ -9,6 +9,8 @@ class StackColorScheme { this.bindMatchMedia(); this.currentScheme = this.getSavedScheme(); + this.dispatchEvent(document.body.dataset.scheme as colorScheme); + if (toggleEl) this.bindClick(toggleEl); From 70cc14fcbe9e229fef7dc2c6a861f1bd6d3c647e Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Thu, 7 Jan 2021 11:28:16 +0100 Subject: [PATCH 9/9] feat(list): display subsections in list style when there are no normal pages (#121) closes https://github.com/CaiJimmy/hugo-theme-stack/issues/116 --- layouts/_default/list.html | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/layouts/_default/list.html b/layouts/_default/list.html index b4efb67..90e5b66 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -42,8 +42,17 @@ {{ end }}
- {{ $subsections := .Sections }} - {{ with $subsections }} + {{- $subsections := .Sections -}} + {{- $pages := .Pages | complement $subsections -}} + + {{- if eq (len $pages) 0 -}} + {{/* If there are no normal pages, display subsections in list style, with pagination */}} + {{/* This happens with taxonomies like categories or tags */}} + {{- $pages = $subsections -}} + {{- $subsections = slice -}} + {{- end -}} + + {{- with $subsections -}}

{{ T "list.subsection" (len $subsections) }}

@@ -52,10 +61,10 @@ {{ end }}
- {{ end }} + {{- end -}} {{/* List only pages that are not a subsection */}} - {{ $paginator := .Paginate (.Pages | complement $subsections) }} + {{ $paginator := .Paginate $pages }}
{{ range $paginator.Pages }} {{ partial "article-list/compact" . }}