mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-29 12:03:31 +08:00
- First implmenetation of the taxonomy "series"
This commit is contained in:
parent
faca44b8a9
commit
a4a7383233
7
archetypes/series.md
Normal file
7
archetypes/series.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: "{{ replace .Name "-" " " | title }}"
|
||||
image:
|
||||
style:
|
||||
background: "#2a9d8f"
|
||||
color: "#fff"
|
||||
---
|
64
assets/icons/forward.svg
Normal file
64
assets/icons/forward.svg
Normal 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
7
assets/icons/series.svg
Normal 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 |
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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:
|
||||
|
13
i18n/en.yaml
13
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
|
||||
|
@ -20,6 +20,12 @@ article:
|
||||
back:
|
||||
other: Indietro
|
||||
|
||||
forward:
|
||||
other: Successivo
|
||||
|
||||
home:
|
||||
other: Casa
|
||||
|
||||
tableOfContents:
|
||||
other: Indice
|
||||
|
||||
|
@ -1,5 +1,19 @@
|
||||
{{ define "body-class" }}template-archives{{ end }}
|
||||
{{ 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" -}}
|
||||
{{- $terms := $taxonomy.Pages -}}
|
||||
{{ if $terms }}
|
||||
|
@ -30,10 +30,10 @@
|
||||
{{- $Width = $thumbnail.Width -}}
|
||||
{{- $Height = $thumbnail.Height -}}
|
||||
{{- end -}}
|
||||
|
||||
<img src="{{ $Permalink }}"
|
||||
|
||||
<img src="{{ $Permalink }}"
|
||||
width="{{ $Width }}"
|
||||
height="{{ $Height }}"
|
||||
height="{{ $Height }}"
|
||||
loading="lazy">
|
||||
{{ else }}
|
||||
<img src="{{ $image.permalink }}" loading="lazy" />
|
||||
@ -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 @@
|
||||
</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{/* 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">
|
||||
{{ range $paginator.Pages }}
|
||||
{{ partial "article-list/compact" . }}
|
||||
@ -78,4 +79,4 @@
|
||||
|
||||
{{ define "right-sidebar" }}
|
||||
{{ partialCached "sidebar/right.html" . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
@ -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 }}
|
||||
<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") }}
|
||||
<div id="article-toolbar">
|
||||
<a href="{{ .Site.BaseURL | relLangURL }}" class="back-home">
|
||||
@ -37,9 +81,41 @@
|
||||
{{ else }}
|
||||
{{ partial "sidebar/left.html" . }}
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ 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") }}
|
||||
<aside class="sidebar right-sidebar sticky">
|
||||
<section class="widget archives">
|
||||
@ -47,11 +123,13 @@
|
||||
{{ partial "helper/icon" "hash" }}
|
||||
</div>
|
||||
<h2 class="widget-title section-title">{{ T "article.tableOfContents" }}</h2>
|
||||
|
||||
|
||||
<div class="widget--toc">
|
||||
{{ .TableOfContents }}
|
||||
</div>
|
||||
</section>
|
||||
</aside>
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
33
layouts/partials/widget/series.html
Normal file
33
layouts/partials/widget/series.html
Normal 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 -}}
|
Loading…
Reference in New Issue
Block a user