aboutsummaryrefslogtreecommitdiff
path: root/themes/hugo-theme-stack/layouts/partials/widget
diff options
context:
space:
mode:
authorAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-11-03 20:08:36 +0300
committerAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-11-03 20:08:36 +0300
commit59c7d4567380d1a9c80e96eb958fdbdd512ce006 (patch)
tree65410cfc10dbc7d060ec23be110662d9b7f6b0e9 /themes/hugo-theme-stack/layouts/partials/widget
новая жизнь блога
Diffstat (limited to 'themes/hugo-theme-stack/layouts/partials/widget')
-rw-r--r--themes/hugo-theme-stack/layouts/partials/widget/archives.html35
-rw-r--r--themes/hugo-theme-stack/layouts/partials/widget/categories.html16
-rw-r--r--themes/hugo-theme-stack/layouts/partials/widget/search.html16
-rw-r--r--themes/hugo-theme-stack/layouts/partials/widget/tag-cloud.html16
-rw-r--r--themes/hugo-theme-stack/layouts/partials/widget/toc.html12
5 files changed, 95 insertions, 0 deletions
diff --git a/themes/hugo-theme-stack/layouts/partials/widget/archives.html b/themes/hugo-theme-stack/layouts/partials/widget/archives.html
new file mode 100644
index 0000000..1f2abc5
--- /dev/null
+++ b/themes/hugo-theme-stack/layouts/partials/widget/archives.html
@@ -0,0 +1,35 @@
+{{- $query := first 1 (where .Context.Site.Pages "Layout" "==" "archives") -}}
+{{- $context := .Context -}}
+{{- $limit := default 5 .Params.limit -}}
+{{- if $query -}}
+ {{- $archivesPage := index $query 0 -}}
+ <section class="widget archives">
+ <div class="widget-icon">
+ {{ partial "helper/icon" "infinity" }}
+ </div>
+ <h2 class="widget-title section-title">{{ T "widget.archives.title" }}</h2>
+
+ {{ $pages := where $context.Site.RegularPages "Type" "in" $context.Site.Params.mainSections }}
+ {{ $notHidden := where $context.Site.RegularPages "Params.hidden" "!=" true }}
+ {{ $filtered := ($pages | intersect $notHidden) }}
+ {{ $archives := $filtered.GroupByDate "2006" }}
+
+ <div class="widget-archive--list">
+ {{ range $index, $item := first (add $limit 1) ($archives) }}
+ {{- $id := lower (replace $item.Key " " "-") -}}
+ <div class="archives-year">
+ <a href="{{ $archivesPage.RelPermalink }}#{{ $id }}">
+ {{ if eq $index $limit }}
+ <span class="year">{{ T "widget.archives.more" }}</span>
+ {{ else }}
+ <span class="year">{{ .Key }}</span>
+ <span class="count">{{ len $item.Pages }}</span>
+ {{ end }}
+ </a>
+ </div>
+ {{ end }}
+ </div>
+ </section>
+{{- else -}}
+ {{- warnf "Archives page not found. Create a page with layout: archives." -}}
+{{- end -}} \ No newline at end of file
diff --git a/themes/hugo-theme-stack/layouts/partials/widget/categories.html b/themes/hugo-theme-stack/layouts/partials/widget/categories.html
new file mode 100644
index 0000000..10c8a35
--- /dev/null
+++ b/themes/hugo-theme-stack/layouts/partials/widget/categories.html
@@ -0,0 +1,16 @@
+{{- $context := .Context -}}
+{{- $limit := default 10 .Params.limit -}}
+<section class="widget tagCloud">
+ <div class="widget-icon">
+ {{ partial "helper/icon" "categories" }}
+ </div>
+ <h2 class="widget-title section-title">{{ T "widget.categoriesCloud.title" }}</h2>
+
+ <div class="tagCloud-tags">
+ {{ range first $limit $context.Site.Taxonomies.categories.ByCount }}
+ <a href="{{ .Page.RelPermalink }}" class="font_size_{{ .Count }}">
+ {{ .Page.Title }}
+ </a>
+ {{ end }}
+ </div>
+</section>
diff --git a/themes/hugo-theme-stack/layouts/partials/widget/search.html b/themes/hugo-theme-stack/layouts/partials/widget/search.html
new file mode 100644
index 0000000..7b0fc73
--- /dev/null
+++ b/themes/hugo-theme-stack/layouts/partials/widget/search.html
@@ -0,0 +1,16 @@
+{{- $query := first 1 (where .Context.Site.Pages "Layout" "==" "search") -}}
+{{- if $query -}}
+ {{- $searchPage := index $query 0 -}}
+ <form action="{{ $searchPage.RelPermalink }}" class="search-form widget" {{ with .OutputFormats.Get "json" -}}data-json="{{ .Permalink }}" {{- end }}>
+ <p>
+ <label>{{ T "search.title" }}</label>
+ <input name="keyword" required placeholder="{{ T `search.placeholder` }}" />
+
+ <button title="{{ T `search.title` }}">
+ {{ partial "helper/icon" "search" }}
+ </button>
+ </p>
+ </form>
+{{- else -}}
+ {{- warnf "Search page not found. Create a page with layout: search." -}}
+{{- end -}} \ No newline at end of file
diff --git a/themes/hugo-theme-stack/layouts/partials/widget/tag-cloud.html b/themes/hugo-theme-stack/layouts/partials/widget/tag-cloud.html
new file mode 100644
index 0000000..e64e5e2
--- /dev/null
+++ b/themes/hugo-theme-stack/layouts/partials/widget/tag-cloud.html
@@ -0,0 +1,16 @@
+{{- $context := .Context -}}
+{{- $limit := default 10 .Params.limit -}}
+<section class="widget tagCloud">
+ <div class="widget-icon">
+ {{ partial "helper/icon" "tag" }}
+ </div>
+ <h2 class="widget-title section-title">{{ T "widget.tagCloud.title" }}</h2>
+
+ <div class="tagCloud-tags">
+ {{ range first $limit $context.Site.Taxonomies.tags.ByCount }}
+ <a href="{{ .Page.RelPermalink }}" class="font_size_{{ .Count }}">
+ {{ .Page.Title }}
+ </a>
+ {{ end }}
+ </div>
+</section> \ No newline at end of file
diff --git a/themes/hugo-theme-stack/layouts/partials/widget/toc.html b/themes/hugo-theme-stack/layouts/partials/widget/toc.html
new file mode 100644
index 0000000..e311de3
--- /dev/null
+++ b/themes/hugo-theme-stack/layouts/partials/widget/toc.html
@@ -0,0 +1,12 @@
+{{ if (.Context.Scratch.Get "TOCEnabled") }}
+ <section class="widget archives">
+ <div class="widget-icon">
+ {{ partial "helper/icon" "hash" }}
+ </div>
+ <h2 class="widget-title section-title">{{ T "article.tableOfContents" }}</h2>
+
+ <div class="widget--toc">
+ {{ .Context.TableOfContents }}
+ </div>
+ </section>
+{{ end }} \ No newline at end of file