- First implmenetation of the taxonomy "series"

This commit is contained in:
Massimo Maggioni 2021-12-29 15:26:17 +01:00
parent faca44b8a9
commit a4a7383233
12 changed files with 322 additions and 23 deletions

7
archetypes/series.md Normal file
View File

@ -0,0 +1,7 @@
---
title: "{{ replace .Name "-" " " | title }}"
image:
style:
background: "#2a9d8f"
color: "#fff"
---

64
assets/icons/forward.svg Normal file
View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
class="icon icon-tabler icon-tabler-chevron-left"
width="24"
height="24"
viewBox="0 0 24 24"
stroke-width="2"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
version="1.1"
id="svg6"
sodipodi:docname="forward.svg"
inkscape:version="0.92.1 r15371">
<metadata
id="metadata12">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs10" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview8"
showgrid="false"
inkscape:zoom="9.8333333"
inkscape:cx="12"
inkscape:cy="12"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="0"
inkscape:current-layer="svg6" />
<path
stroke="none"
d="M0 0h24v24H0z"
id="path2" />
<polyline
points="15 6 9 12 15 18"
id="polyline4"
transform="rotate(-180,12.005071,12)" />
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

7
assets/icons/series.svg Normal file
View File

@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5" />
<path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5" />
</svg>

After

Width:  |  Height:  |  Size: 418 B

View File

@ -93,6 +93,7 @@
background: var(--card-background); background: var(--card-background);
border-radius: var(--tag-border-radius); border-radius: var(--tag-border-radius);
color: var(--card-text-color-tertiary); color: var(--card-text-color-tertiary);
margin-top: -10px;
margin-right: 30px; margin-right: 30px;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@ -114,6 +115,36 @@
height: 20px; 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 { span {
font-weight: 500; font-weight: 500;
white-space: nowrap; white-space: nowrap;

View File

@ -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);
}
}
}
}

View File

@ -132,6 +132,7 @@ params:
widgets: widgets:
enabled: enabled:
- search - search
# - series
- archives - archives
- tag-cloud - tag-cloud
@ -141,6 +142,9 @@ params:
tagCloud: tagCloud:
limit: 10 limit: 10
series:
limit: 5
opengraph: opengraph:
twitter: twitter:
# Your Twitter username # Your Twitter username
@ -168,6 +172,12 @@ params:
content: content:
enabled: true enabled: true
taxonomies:
tag: "tags"
category: "categories"
series: "series"
### Custom menu ### Custom menu
### See https://docs.stack.jimmycai.com/configuration/custom-menu.html ### 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 ### To remove about, archive and search page menu item, remove `menu` field from their FrontMatter
@ -206,6 +216,10 @@ related:
- name: categories - name: categories
weight: 200 weight: 200
- name: series
weight: 300
markup: markup:
goldmark: goldmark:
renderer: renderer:

View File

@ -20,6 +20,12 @@ article:
back: back:
other: Back other: Back
forward:
other: Forward
home:
other: Home
tableOfContents: tableOfContents:
other: Table of contents other: Table of contents
@ -52,6 +58,13 @@ widget:
title: title:
other: Tags other: Tags
series:
title:
other: Series
more:
other: More
search: search:
title: title:
other: Search other: Search

View File

@ -20,6 +20,12 @@ article:
back: back:
other: Indietro other: Indietro
forward:
other: Successivo
home:
other: Casa
tableOfContents: tableOfContents:
other: Indice other: Indice

View File

@ -1,5 +1,19 @@
{{ define "body-class" }}template-archives{{ end }} {{ define "body-class" }}template-archives{{ end }}
{{ define "main" }} {{ define "main" }}
{{- $taxonomy := $.Site.GetPage "taxonomyTerm" "series" -}}
{{- $terms := $taxonomy.Pages -}}
{{ if $terms }}
<h2 class="section-title">{{ $taxonomy.Title }}</h2>
<div class="subsection-list">
<div class="article-list--tile">
{{ range $terms }}
{{ partial "article-list/tile" (dict "context" . "size" "250x150" "Type" "taxonomy") }}
{{ end }}
</div>
</div>
{{ end }}
{{- $taxonomy := $.Site.GetPage "taxonomyTerm" "categories" -}} {{- $taxonomy := $.Site.GetPage "taxonomyTerm" "categories" -}}
{{- $terms := $taxonomy.Pages -}} {{- $terms := $taxonomy.Pages -}}
{{ if $terms }} {{ if $terms }}

View File

@ -64,7 +64,8 @@
{{- end -}} {{- end -}}
{{/* List only pages that are not a subsection */}} {{/* List only pages that are not a subsection */}}
{{ $paginator := .Paginate $pages }} {{/* $paginator := .Paginate $pages */}}
{{ $paginator := .Paginate ($pages.ByParam "series_weight") }}
<section class="article-list--compact"> <section class="article-list--compact">
{{ range $paginator.Pages }} {{ range $paginator.Pages }}
{{ partial "article-list/compact" . }} {{ partial "article-list/compact" . }}

View File

@ -1,15 +1,32 @@
{{ define "body-class" }} {{ define "body-class" }}
{{ 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 }} {{ $TOCEnabled := default (default false .Site.Params.article.toc) .Params.toc }}
{{- .Scratch.Set "hasTOC" (and (ge (len .TableOfContents) 100) $TOCEnabled) -}} {{- .Scratch.Set "hasTOC" (and (ge (len .TableOfContents) 100) $TOCEnabled) -}}
article-page {{ if (.Scratch.Get "hasTOC") }}has-toc{{ end }} article-page {{ if (.Scratch.Get "hasTOC") }}has-toc{{ end }}
/* article-page */
{{ end }}
{{ end }} {{ end }}
{{ define "container-class" }} {{ define "container-class" }}
{{ if isset .Params "series" }}
{{ if (.Scratch.Get "hasTOC") }} {{ if (.Scratch.Get "hasTOC") }}
extended extended
{{ else }} {{ else }}
on-phone--column {{ if .Site.Params.widgets.enabled }}extended{{ else }}compact{{ end }} on-phone--column {{ if .Site.Params.widgets.enabled }}extended{{ else }}compact{{ end }}
{{ end }} {{ end }}
{{ else }}
{{ if (.Scratch.Get "hasTOC") }}
extended
{{ else }}
on-phone--column {{ if .Site.Params.widgets.enabled }}extended{{ else }}compact{{ end }}
{{ end }}
{{ end }}
{{ end }} {{ end }}
{{ define "main" }} {{ define "main" }}
@ -27,6 +44,33 @@
{{ end }} {{ end }}
{{ define "left-sidebar" }} {{ define "left-sidebar" }}
{{ if isset .Params "series" }}
{{ if eq (.Scratch.Get "current_w") 1 }}
<div id="article-toolbar">
<a href="{{ .Site.BaseURL }}" class="back-home">
{{ (resources.Get "icons/back.svg").Content | safeHTML }}
<span>{{ T "article.home" }}</span>
</a>
</div>
{{ else }}
{{ range where (where .Site.Pages "Params.series_weight" (add (.Scratch.Get "current_w" | int) -1)) "Params.series" (.Scratch.Get "series_name") }}
<div id="article-toolbar">
<a href="{{ .Permalink }}" class="back-home">
{{ (resources.Get "icons/back.svg").Content | safeHTML }}
<span>{{ T "article.back" }}</span>
</a>
<br></br>
<a href="{{ .Site.BaseURL }}" class="back-home">
{{ (resources.Get "icons/back.svg").Content | safeHTML }}
<span>{{ T "article.home" }}</span>
</a>
</div>
{{ end }}
{{ end }}
{{ else }}
{{ if (.Scratch.Get "hasTOC") }} {{ if (.Scratch.Get "hasTOC") }}
<div id="article-toolbar"> <div id="article-toolbar">
<a href="{{ .Site.BaseURL | relLangURL }}" class="back-home"> <a href="{{ .Site.BaseURL | relLangURL }}" class="back-home">
@ -37,9 +81,41 @@
{{ else }} {{ else }}
{{ partial "sidebar/left.html" . }} {{ partial "sidebar/left.html" . }}
{{ end }} {{ end }}
{{ end }}
{{ end }} {{ end }}
{{ define "right-sidebar" }} {{ define "right-sidebar" }}
{{ if isset .Params "series" }}
<aside class="sidebar right-sidebar sticky">
{{ range where (where .Site.Pages "Params.series_weight" (add (.Scratch.Get "current_w" | int) 1)) "Params.series" (.Scratch.Get "series_name") }}
<div id="article-toolbar">
<a href="{{ .Permalink }}" class="forward-home">
<span>{{ T "article.forward" }}</span>
{{ (resources.Get "icons/forward.svg").Content | safeHTML }}
</a>
</div>
<br></br>
{{ end }}
{{ if (.Scratch.Get "hasTOC") }}
<section class="widget series">
<div class="widget-icon">
{{ partial "helper/icon" "hash" }}
</div>
<h2 class="widget-title section-title">{{ T "article.tableOfContents" }}</h2>
<div class="widget--toc">
{{ .TableOfContents }}
</div>
</section>
{{ end }}
{{/* partial "widget/series" . */}}
{{/* partial "widget/tag-cloud" . */}}
</aside>
{{ else }}
{{ if (.Scratch.Get "hasTOC") }} {{ if (.Scratch.Get "hasTOC") }}
<aside class="sidebar right-sidebar sticky"> <aside class="sidebar right-sidebar sticky">
<section class="widget archives"> <section class="widget archives">
@ -54,4 +130,6 @@
</section> </section>
</aside> </aside>
{{ end }} {{ end }}
{{ end }}
{{ end }} {{ end }}

View File

@ -0,0 +1,33 @@
{{- $query := first 1 (where .Site.Pages "Layout" "==" "archives") -}}
{{- if $query -}}
{{- $archivesPage := index $query 0 -}}
<section class="widget series">
<div class="widget-icon">
{{ partial "helper/icon" "series" }}
</div>
<h2 class="widget-title section-title">{{ T "widget.series.title" }}</h2>
{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{ $notHidden := where .Site.RegularPages "Params.hidden" "!=" true }}
{{ $filtered := ($pages | intersect $notHidden) }}
{{ $archives := $filtered.GroupByParam "series" }}
<div class="widget-series--list">
{{ range $index, $item := first (add .Site.Params.widgets.series.limit 1) ($archives) }}
{{- $id := lower (replace $item.Key " " "-") -}}
<div class="series-stream">
<a href="{{ $.Site.BaseURL}}series/{{ $id }}">
{{ if eq $index $.Site.Params.widgets.series.limit }}
<span class="stream">{{ T "widget.series.more" }}</span>
{{ else }}
<span class="stream">{{ .Key }}</span>
<span class="count">{{ len $item.Pages }}</span>
{{ end }}
</a>
</div>
{{ end }}
</div>
</section>
{{- else -}}
{{- warnf "Series page not found. Create a page with layout: series." -}}
{{- end -}}