Support categories again, but hopefully a bit better

This commit is contained in:
BBaoVanC 2022-05-06 20:16:41 -05:00
parent 0888356292
commit 311d846cb8
Signed by: bbaovanc
GPG Key ID: 18089E4E3CCF1D3A
9 changed files with 122 additions and 0 deletions

View File

@ -10,6 +10,9 @@ draft: true
authors: authors:
- {{ with .Site.Author.name }}{{ . }}{{ else }}John Doe{{ end }} - {{ with .Site.Author.name }}{{ . }}{{ else }}John Doe{{ end }}
categories:
- archetype-stuff
tags: tags:
- awesome - awesome

View File

@ -0,0 +1,15 @@
---
title: {{ replace .Name "-" " " | title }}
---
A short summary of what the category is about.
<!--more-->
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 (`<!--more-->`)
or else the summary won't be shown.

View File

@ -113,6 +113,7 @@
margin-bottom: 15px; margin-bottom: 15px;
} }
.categories,
.tags, .tags,
.series { .series {
margin-top: 10px; 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 */ /* Tags list format */
.tag-list ul { .tag-list ul {
display: flex; display: flex;

View File

@ -7,6 +7,7 @@ params:
readingtime: true readingtime: true
taxonomies: taxonomies:
category: categories
tag: tags tag: tags
author: authors author: authors
series: series series: series

View File

@ -0,0 +1,27 @@
{{ define "main" }}
<h1>
{{ partial "icon.html" "folder" }}
{{ .Title | markdownify }}
</h1>
<div class="category-list">
{{ with .Data.Terms.Alphabetical }}
<ul>
{{ range . }}
{{ with .Page }}
<li>
<a href="{{ .Permalink }}">
<p>{{ .Title | markdownify }}</p>
</a>
{{ partial "description-or-summary.html" . }}
</li>
{{ end }}
{{ end }}
</ul>
{{ else }}
<div>
{{ i18n "no_posts" }}
</div>
{{ end }}
</div>
{{ end }}

View File

@ -0,0 +1,27 @@
{{ define "main" }}
<h1>
{{ partial "icon.html" "folder" }}
{{ .Title | markdownify }}
{{ partial "rss-link.html" . }}
</h1>
{{ with .Content }}
{{ . }}
{{ end }}
<div class="page-list">
{{ with .Paginator.Pages }}
<ul>
{{ range . }}
<li>{{ .Render "summary/post" }}</li>
{{ end }}
</ul>
{{ else }}
<div>
{{ i18n "no_posts" }}
</div>
{{ end }}
</div>
{{ partial "pagination.html" . }}
{{ end }}

View File

@ -0,0 +1,11 @@
{{ with (.GetTerms "categories") }}
{{ $categories := slice }}
{{ range . }}
{{ $categories = $categories | append (printf `<a href="%s">%s</a>` .Permalink .LinkTitle) }}
{{ end }}
<div class="categories" aria-label="{{ i18n "aria_post_meta_categories" }}">
{{ partial "icon.html" "folder" }}
{{ delimit $categories ", " }}
</div>
{{ end }}

View File

@ -25,6 +25,7 @@
{{ partial "post-meta-item/translations.html" . }} {{ partial "post-meta-item/translations.html" . }}
{{ partial "post-meta-item/readingtime.html" . }} {{ partial "post-meta-item/readingtime.html" . }}
{{ partial "post-meta-item/viewsource.html" . }} {{ partial "post-meta-item/viewsource.html" . }}
{{ partial "post-meta-item/categories.html" . }}
{{ partial "post-meta-item/tags.html" . }} {{ partial "post-meta-item/tags.html" . }}
</div> </div>
{{ end }} {{ end }}

View File

@ -13,6 +13,7 @@
{{ partial "post-meta-item/translations.html" . }} {{ partial "post-meta-item/translations.html" . }}
{{ partial "post-meta-item/readingtime.html" . }} {{ partial "post-meta-item/readingtime.html" . }}
{{ partial "post-meta-item/series.html" . }} {{ partial "post-meta-item/series.html" . }}
{{ partial "post-meta-item/categories.html" . }}
{{ partial "post-meta-item/tags.html" . }} {{ partial "post-meta-item/tags.html" . }}
</div> </div>
{{ end }} {{ end }}