From a4a7383233df4507888710ea2bfd1dc6a0f1b457 Mon Sep 17 00:00:00 2001 From: Massimo Maggioni <94243057+MassimoMaggioni@users.noreply.github.com> Date: Wed, 29 Dec 2021 15:26:17 +0100 Subject: [PATCH] - First implmenetation of the taxonomy "series" --- archetypes/series.md | 7 ++ assets/icons/forward.svg | 64 +++++++++++++++++ assets/icons/series.svg | 7 ++ assets/scss/partials/layout/article.scss | 33 ++++++++- assets/scss/partials/widgets.scss | 31 +++++++++ exampleSite/config.yaml | 34 ++++++--- i18n/en.yaml | 13 ++++ i18n/it.yaml | 6 ++ layouts/_default/archives.html | 14 ++++ layouts/_default/list.html | 15 ++-- layouts/_default/single.html | 88 ++++++++++++++++++++++-- layouts/partials/widget/series.html | 33 +++++++++ 12 files changed, 322 insertions(+), 23 deletions(-) create mode 100644 archetypes/series.md create mode 100644 assets/icons/forward.svg create mode 100644 assets/icons/series.svg create mode 100644 layouts/partials/widget/series.html diff --git a/archetypes/series.md b/archetypes/series.md new file mode 100644 index 0000000..b2133f3 --- /dev/null +++ b/archetypes/series.md @@ -0,0 +1,7 @@ +--- +title: "{{ replace .Name "-" " " | title }}" +image: +style: + background: "#2a9d8f" + color: "#fff" +--- diff --git a/assets/icons/forward.svg b/assets/icons/forward.svg new file mode 100644 index 0000000..0b55dcd --- /dev/null +++ b/assets/icons/forward.svg @@ -0,0 +1,64 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/assets/icons/series.svg b/assets/icons/series.svg new file mode 100644 index 0000000..3c87803 --- /dev/null +++ b/assets/icons/series.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/scss/partials/layout/article.scss b/assets/scss/partials/layout/article.scss index 7059853..fac471d 100644 --- a/assets/scss/partials/layout/article.scss +++ b/assets/scss/partials/layout/article.scss @@ -93,7 +93,8 @@ background: var(--card-background); border-radius: var(--tag-border-radius); color: var(--card-text-color-tertiary); - margin-right: 30px; + margin-top: -10px; + margin-right: 30px; display: inline-flex; align-items: center; font-size: 1.4rem; @@ -114,6 +115,36 @@ height: 20px; } + span { + font-weight: 500; + white-space: nowrap; + } + } + .forward-home { + background: var(--card-background); + border-radius: var(--tag-border-radius); + color: var(--card-text-color-tertiary); + margin-right: 30px; + display: inline; + align-items: center; + font-size: 1.4rem; + text-transform: uppercase; + padding: 10px 10px 10px 15px; + + transition: box-shadow 0.3s ease; + + box-shadow: var(--shadow-l1); + + &:hover { + box-shadow: var(--shadow-l2); + } + + svg { + margin-right: 5px; + width: 20px; + height: 20px; + } + span { font-weight: 500; white-space: nowrap; diff --git a/assets/scss/partials/widgets.scss b/assets/scss/partials/widgets.scss index 33a02dd..1bc1914 100644 --- a/assets/scss/partials/widgets.scss +++ b/assets/scss/partials/widgets.scss @@ -64,3 +64,34 @@ } } } + +/* Series widget */ +.widget.series { + .widget-series--list { + border-radius: var(--card-border-radius); + box-shadow: var(--shadow-l1); + background-color: var(--card-background); + } + + .series-stream { + &:not(:last-of-type) { + border-bottom: 1.5px solid var(--card-separator-color); + } + + a { + font-size: 1.4rem; + padding: 18px 25px; + display: flex; + + span.stream { + flex: 1; + color: var(--card-text-color-main); + font-weight: bold; + } + + span.count { + color: var(--card-text-color-tertiary); + } + } + } +} diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index ee7a8a3..330d0e9 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -119,19 +119,20 @@ params: emitMetadata: 0 gitalk: - owner: - admin: - repo: - clientID: - clientSecret: - + owner: + admin: + repo: + clientID: + clientSecret: + cusdis: - host: - id: + host: + id: widgets: enabled: - search +# - series - archives - tag-cloud @@ -141,6 +142,9 @@ params: tagCloud: limit: 10 + series: + limit: 5 + opengraph: twitter: # Your Twitter username @@ -168,6 +172,12 @@ params: content: enabled: true +taxonomies: + tag: "tags" + category: "categories" + series: "series" + + ### Custom menu ### See https://docs.stack.jimmycai.com/configuration/custom-menu.html ### To remove about, archive and search page menu item, remove `menu` field from their FrontMatter @@ -181,14 +191,14 @@ menu: ### For demonstration purpose, the home link will be open in a new tab newTab: true icon: home - + social: - identifier: github name: GitHub url: https://github.com/CaiJimmy/hugo-theme-stack params: icon: brand-github - + - identifier: twitter name: Twitter url: https://twitter.com @@ -206,6 +216,10 @@ related: - name: categories weight: 200 + - name: series + weight: 300 + + markup: goldmark: renderer: diff --git a/i18n/en.yaml b/i18n/en.yaml index 0197d89..d4b26d6 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -20,6 +20,12 @@ article: back: other: Back + forward: + other: Forward + + home: + other: Home + tableOfContents: other: Table of contents @@ -52,6 +58,13 @@ widget: title: other: Tags + series: + title: + other: Series + + more: + other: More + search: title: other: Search diff --git a/i18n/it.yaml b/i18n/it.yaml index 6c4114c..a8d7cdf 100644 --- a/i18n/it.yaml +++ b/i18n/it.yaml @@ -20,6 +20,12 @@ article: back: other: Indietro + forward: + other: Successivo + + home: + other: Casa + tableOfContents: other: Indice diff --git a/layouts/_default/archives.html b/layouts/_default/archives.html index 321aa6d..da1c6d9 100644 --- a/layouts/_default/archives.html +++ b/layouts/_default/archives.html @@ -1,5 +1,19 @@ {{ define "body-class" }}template-archives{{ end }} {{ define "main" }} + + {{- $taxonomy := $.Site.GetPage "taxonomyTerm" "series" -}} + {{- $terms := $taxonomy.Pages -}} + {{ if $terms }} +

{{ $taxonomy.Title }}

+
+
+ {{ range $terms }} + {{ partial "article-list/tile" (dict "context" . "size" "250x150" "Type" "taxonomy") }} + {{ end }} +
+
+ {{ end }} + {{- $taxonomy := $.Site.GetPage "taxonomyTerm" "categories" -}} {{- $terms := $taxonomy.Pages -}} {{ if $terms }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 90e5b66..e9da03e 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -30,10 +30,10 @@ {{- $Width = $thumbnail.Width -}} {{- $Height = $thumbnail.Height -}} {{- end -}} - - {{ else }} @@ -44,7 +44,7 @@ {{- $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 */}} @@ -62,9 +62,10 @@ {{- end -}} - + {{/* List only pages that are not a subsection */}} - {{ $paginator := .Paginate $pages }} + {{/* $paginator := .Paginate $pages */}} + {{ $paginator := .Paginate ($pages.ByParam "series_weight") }}
{{ range $paginator.Pages }} {{ partial "article-list/compact" . }} @@ -78,4 +79,4 @@ {{ define "right-sidebar" }} {{ partialCached "sidebar/right.html" . }} -{{ end }} \ No newline at end of file +{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 8b21c52..3e962b4 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,22 +1,39 @@ {{ define "body-class" }} - {{ $TOCEnabled := default (default false .Site.Params.article.toc) .Params.toc }} - {{- .Scratch.Set "hasTOC" (and (ge (len .TableOfContents) 100) $TOCEnabled) -}} - article-page {{ if (.Scratch.Get "hasTOC") }}has-toc{{ end }} + {{ if isset .Params "series" }} + {{ $TOCEnabled := default (default false .Site.Params.article.toc) .Params.toc }} + {{- .Scratch.Set "hasTOC" (and (ge (len .TableOfContents) 100) $TOCEnabled) -}} + {{- .Scratch.Set "current_w" .Params.series_weight -}} + {{- .Scratch.Set "series_name" .Params.series -}} + article-page has-toc + {{ else }} + {{ $TOCEnabled := default (default false .Site.Params.article.toc) .Params.toc }} + {{- .Scratch.Set "hasTOC" (and (ge (len .TableOfContents) 100) $TOCEnabled) -}} + article-page {{ if (.Scratch.Get "hasTOC") }}has-toc{{ end }} + /* article-page */ + {{ end }} {{ end }} {{ define "container-class" }} + {{ if isset .Params "series" }} + {{ if (.Scratch.Get "hasTOC") }} + extended + {{ else }} + on-phone--column {{ if .Site.Params.widgets.enabled }}extended{{ else }}compact{{ end }} + {{ end }} + {{ else }} {{ if (.Scratch.Get "hasTOC") }} extended {{ else }} on-phone--column {{ if .Site.Params.widgets.enabled }}extended{{ else }}compact{{ end }} {{ end }} + {{ end }} {{ end }} {{ define "main" }} {{ partial "article/article.html" . }} {{ partial "article/components/related-contents" . }} - + {{ if not (eq .Params.comments false) }} {{ partial "comments/include" . }} {{ end }} @@ -27,6 +44,33 @@ {{ end }} {{ define "left-sidebar" }} + {{ if isset .Params "series" }} + + {{ if eq (.Scratch.Get "current_w") 1 }} +
+ + {{ (resources.Get "icons/back.svg").Content | safeHTML }} + {{ T "article.home" }} + +
+ {{ else }} + {{ range where (where .Site.Pages "Params.series_weight" (add (.Scratch.Get "current_w" | int) -1)) "Params.series" (.Scratch.Get "series_name") }} +
+ + {{ (resources.Get "icons/back.svg").Content | safeHTML }} + {{ T "article.back" }} + +

+ + {{ (resources.Get "icons/back.svg").Content | safeHTML }} + {{ T "article.home" }} + +
+ {{ end }} + {{ end }} + + {{ else }} + {{ if (.Scratch.Get "hasTOC") }}
@@ -37,9 +81,41 @@ {{ else }} {{ partial "sidebar/left.html" . }} {{ end }} + + {{ end }} {{ end }} {{ define "right-sidebar" }} + {{ if isset .Params "series" }} + + + + {{ else }} + {{ if (.Scratch.Get "hasTOC") }}

{{ T "article.tableOfContents" }}

- +
{{ .TableOfContents }}
{{ end }} + + {{ end }} {{ end }} diff --git a/layouts/partials/widget/series.html b/layouts/partials/widget/series.html new file mode 100644 index 0000000..ea5d647 --- /dev/null +++ b/layouts/partials/widget/series.html @@ -0,0 +1,33 @@ +{{- $query := first 1 (where .Site.Pages "Layout" "==" "archives") -}} +{{- if $query -}} + {{- $archivesPage := index $query 0 -}} +
+
+ {{ partial "helper/icon" "series" }} +
+

{{ T "widget.series.title" }}

+ + {{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }} + {{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }} + {{ $filtered := ($pages | intersect $notHidden) }} + {{ $archives := $filtered.GroupByParam "series" }} + +
+ {{ range $index, $item := first (add .Site.Params.widgets.series.limit 1) ($archives) }} + {{- $id := lower (replace $item.Key " " "-") -}} + + {{ end }} +
+
+{{- else -}} + {{- warnf "Series page not found. Create a page with layout: series." -}} +{{- end -}}