diff options
author | Felix Niederwanger <felix.niederwanger@suse.com> | 2022-03-04 01:47:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-04 01:47:10 +0300 |
commit | e22664be13a89b7e0401c3652340569316bb417e (patch) | |
tree | de714d7fd47a8793191cb0f2fa2be0c66ce898ce | |
parent | d806226ec8d1f7eb0a0596609bfcc143785f7f55 (diff) |
feat(widget): add category widget (#475)
* Add category widget
Adds the ability to add a category to the widgets.
* Adapt to new widget scheme
Co-authored-by: Jimmy Cai <github@jimmycai.com>
-rw-r--r-- | assets/icons/categories.svg | 9 | ||||
-rw-r--r-- | i18n/en.yaml | 3 | ||||
-rw-r--r-- | layouts/partials/widget/categories.html | 16 |
3 files changed, 28 insertions, 0 deletions
diff --git a/assets/icons/categories.svg b/assets/icons/categories.svg new file mode 100644 index 0000000..e00ab1d --- /dev/null +++ b/assets/icons/categories.svg @@ -0,0 +1,9 @@ +<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-hash" 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"/> + <line x1="5" y1="9" x2="19" y2="9" /> + <line x1="5" y1="15" x2="19" y2="15" /> + <line x1="11" y1="4" x2="7" y2="20" /> + <line x1="17" y1="4" x2="13" y2="20" /> +</svg> + + diff --git a/i18n/en.yaml b/i18n/en.yaml index 0197d89..3d0ed03 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -51,6 +51,9 @@ widget: tagCloud: title: other: Tags + categoriesCloud: + title: + other: Categories search: title: diff --git a/layouts/partials/widget/categories.html b/layouts/partials/widget/categories.html new file mode 100644 index 0000000..10c8a35 --- /dev/null +++ b/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> |