From 311d846cb8096b109b62f2bc9348f8018ddbb428 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Fri, 6 May 2022 20:16:41 -0500 Subject: [PATCH] Support categories again, but hopefully a bit better --- archetypes/blog/index.md | 3 ++ archetypes/categories/_index.md | 15 ++++++++ assets/css/bobastyle.css | 36 +++++++++++++++++++ config.yaml | 1 + layouts/categories/list.html | 27 ++++++++++++++ layouts/categories/term.html | 27 ++++++++++++++ .../partials/post-meta-item/categories.html | 11 ++++++ layouts/partials/post-metadata/full.html | 1 + layouts/partials/post-metadata/short.html | 1 + 9 files changed, 122 insertions(+) create mode 100644 archetypes/categories/_index.md create mode 100644 layouts/categories/list.html create mode 100644 layouts/categories/term.html create mode 100644 layouts/partials/post-meta-item/categories.html diff --git a/archetypes/blog/index.md b/archetypes/blog/index.md index c01cb8f..4b95267 100644 --- a/archetypes/blog/index.md +++ b/archetypes/blog/index.md @@ -10,6 +10,9 @@ draft: true authors: - {{ with .Site.Author.name }}{{ . }}{{ else }}John Doe{{ end }} +categories: + - archetype-stuff + tags: - awesome diff --git a/archetypes/categories/_index.md b/archetypes/categories/_index.md new file mode 100644 index 0000000..a8dbf2f --- /dev/null +++ b/archetypes/categories/_index.md @@ -0,0 +1,15 @@ +--- + +title: {{ replace .Name "-" " " | title }} + +--- + +A short summary of what the category is about. + + + +Optionally provide more information about the category here. This part will only +show on the category page, not on the category list page. + +If you delete this section, DO NOT delete the summary separator (``) +or else the summary won't be shown. diff --git a/assets/css/bobastyle.css b/assets/css/bobastyle.css index c25565c..3f012bb 100644 --- a/assets/css/bobastyle.css +++ b/assets/css/bobastyle.css @@ -113,6 +113,7 @@ margin-bottom: 15px; } +.categories, .tags, .series { margin-top: 10px; @@ -133,6 +134,41 @@ +/* Category list format */ +.category-list ul { + display: flex; + flex-direction: column; + list-style: none; + gap: 10px; + padding: 0; +} + +.category-list li { + display: flex; + flex-direction: row; + gap: 20px; + background-color: var(--background-2); + padding: 8px 12px; + border-radius: 8px; +} + +@media (max-width: 360px) { + .category-list li { + flex-direction: column; + gap: 0; + } +} + +.category-list li > a, +.category-list li > p { +} + +.category-list p { + margin: 0; +} + + + /* Tags list format */ .tag-list ul { display: flex; diff --git a/config.yaml b/config.yaml index b9dbc45..f24c261 100644 --- a/config.yaml +++ b/config.yaml @@ -7,6 +7,7 @@ params: readingtime: true taxonomies: + category: categories tag: tags author: authors series: series diff --git a/layouts/categories/list.html b/layouts/categories/list.html new file mode 100644 index 0000000..9eb8c54 --- /dev/null +++ b/layouts/categories/list.html @@ -0,0 +1,27 @@ +{{ define "main" }} +

+ {{ partial "icon.html" "folder" }} + {{ .Title | markdownify }} +

+ +
+ {{ with .Data.Terms.Alphabetical }} + + {{ else }} +
+ {{ i18n "no_posts" }} +
+ {{ end }} +
+{{ end }} diff --git a/layouts/categories/term.html b/layouts/categories/term.html new file mode 100644 index 0000000..8fc31fa --- /dev/null +++ b/layouts/categories/term.html @@ -0,0 +1,27 @@ +{{ define "main" }} +

+ {{ partial "icon.html" "folder" }} + {{ .Title | markdownify }} + {{ partial "rss-link.html" . }} +

+ + {{ with .Content }} + {{ . }} + {{ end }} + +
+ {{ with .Paginator.Pages }} + + {{ else }} +
+ {{ i18n "no_posts" }} +
+ {{ end }} +
+ + {{ partial "pagination.html" . }} +{{ end }} diff --git a/layouts/partials/post-meta-item/categories.html b/layouts/partials/post-meta-item/categories.html new file mode 100644 index 0000000..3e53557 --- /dev/null +++ b/layouts/partials/post-meta-item/categories.html @@ -0,0 +1,11 @@ +{{ with (.GetTerms "categories") }} + {{ $categories := slice }} + {{ range . }} + {{ $categories = $categories | append (printf `%s` .Permalink .LinkTitle) }} + {{ end }} + +
+ {{ partial "icon.html" "folder" }} + {{ delimit $categories ", " }} +
+{{ end }} diff --git a/layouts/partials/post-metadata/full.html b/layouts/partials/post-metadata/full.html index 275ba8a..a6ce14c 100644 --- a/layouts/partials/post-metadata/full.html +++ b/layouts/partials/post-metadata/full.html @@ -25,6 +25,7 @@ {{ partial "post-meta-item/translations.html" . }} {{ partial "post-meta-item/readingtime.html" . }} {{ partial "post-meta-item/viewsource.html" . }} + {{ partial "post-meta-item/categories.html" . }} {{ partial "post-meta-item/tags.html" . }} {{ end }} diff --git a/layouts/partials/post-metadata/short.html b/layouts/partials/post-metadata/short.html index 9d0e843..bae4921 100644 --- a/layouts/partials/post-metadata/short.html +++ b/layouts/partials/post-metadata/short.html @@ -13,6 +13,7 @@ {{ partial "post-meta-item/translations.html" . }} {{ partial "post-meta-item/readingtime.html" . }} {{ partial "post-meta-item/series.html" . }} + {{ partial "post-meta-item/categories.html" . }} {{ partial "post-meta-item/tags.html" . }} {{ end }}