From e22664be13a89b7e0401c3652340569316bb417e Mon Sep 17 00:00:00 2001 From: Felix Niederwanger Date: Thu, 3 Mar 2022 23:47:10 +0100 Subject: [PATCH 1/2] 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 --- assets/icons/categories.svg | 9 +++++++++ i18n/en.yaml | 3 +++ layouts/partials/widget/categories.html | 16 ++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 assets/icons/categories.svg create mode 100644 layouts/partials/widget/categories.html 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 @@ + + + + + + + + + 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 -}} +
+
+ {{ partial "helper/icon" "categories" }} +
+

{{ T "widget.categoriesCloud.title" }}

+ +
+ {{ range first $limit $context.Site.Taxonomies.categories.ByCount }} + + {{ .Page.Title }} + + {{ end }} +
+
From 86ad00cf8cbbc6b212d68afcedf28cda8b552690 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Thu, 3 Mar 2022 22:48:26 +0000 Subject: [PATCH 2/2] doc: add categories widget to exampleSite --- exampleSite/config.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index b2fe1d3..cfad0a0 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -147,6 +147,9 @@ params: - type: archives params: limit: 5 + - type: categories + params: + limit: 10 - type: tag-cloud params: limit: 10