💄 Add support subcategory feature.
This commit is contained in:
parent
d44d4c2a79
commit
05dba844d7
@ -15,14 +15,22 @@
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.category-list-item {
|
||||
margin: 5px 10px;
|
||||
.category-list-item:before {
|
||||
font-family: var(--fa-style-family,"Font Awesome 6 Free");
|
||||
font-weight: var(--fa-style,900);
|
||||
content: "\f07c"
|
||||
}
|
||||
|
||||
.category-list-item {
|
||||
margin: 5px 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.category-list-count {
|
||||
color: $grey;
|
||||
padding: 0 2px;
|
||||
|
||||
&::before {
|
||||
content: ' (';
|
||||
@ -33,7 +41,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
.category-list-child {
|
||||
padding-left: 10px;
|
||||
.category-children-list {
|
||||
padding-left: 38px;
|
||||
list-style: none;
|
||||
|
||||
.category-children-list-item:before {
|
||||
font-family: var(--fa-style-family,"Font Awesome 6 Free");
|
||||
font-weight: var(--fa-style,900);
|
||||
content: "\f0ae";
|
||||
}
|
||||
|
||||
.category-children-list-item {
|
||||
font-size: 0.925em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ date: 2022-09-10T21:02:32+08:00
|
||||
lastmod: 2022-09-10T21:02:32+08:00
|
||||
|
||||
categories:
|
||||
- 示例
|
||||
- 示例文章
|
||||
|
||||
tags:
|
||||
- 自定义
|
||||
- 个性化
|
||||
|
@ -7,7 +7,9 @@ date: 2022-06-04T19:46:45+08:00
|
||||
lastmod: 2022-06-04T19:46:45+08:00
|
||||
|
||||
categories:
|
||||
- 示例
|
||||
- 示例文章
|
||||
- 语法
|
||||
|
||||
tags:
|
||||
- 表情
|
||||
- emoji
|
||||
|
@ -7,7 +7,7 @@ date: 2022-06-01T15:59:41+08:00
|
||||
lastmod: 2022-06-01T15:59:41+08:00
|
||||
|
||||
categories:
|
||||
- 示例
|
||||
- 示例文章
|
||||
tags:
|
||||
- Hugo
|
||||
- NexT
|
||||
|
@ -6,10 +6,11 @@ lastmod: 2022-06-03T16:43:23+08:00
|
||||
date: 2022-06-02T11:52:03+08:00
|
||||
|
||||
categories:
|
||||
- 博客
|
||||
- 开始建站
|
||||
|
||||
tags:
|
||||
- Hugo
|
||||
- 开始
|
||||
- Hugo
|
||||
- 开始
|
||||
|
||||
url: post/hello-world.html
|
||||
toc: true
|
||||
|
@ -10,7 +10,9 @@ author: Mainroad
|
||||
originLink: https://mainroad-demo.netlify.app/post/basic-elements/
|
||||
|
||||
categories:
|
||||
- 示例
|
||||
- 示例文章
|
||||
- 语法
|
||||
|
||||
tags:
|
||||
- Markdown
|
||||
- 语法
|
||||
|
@ -7,7 +7,8 @@ date: 2022-09-11T10:16:02+08:00
|
||||
lastmod: 2022-09-11T10:16:02+08:00
|
||||
|
||||
categories:
|
||||
- 示例
|
||||
- 第三方引入
|
||||
- 数学公式
|
||||
tags:
|
||||
- 数学公式
|
||||
- mathjax
|
||||
|
@ -7,7 +7,8 @@ date: 2022-09-18T20:58:13+08:00
|
||||
lastmod: 2022-09-18T20:58:13+08:00
|
||||
|
||||
categories:
|
||||
- 示例
|
||||
- 第三方引入
|
||||
- 图序功能
|
||||
tags:
|
||||
- 流程图
|
||||
- 时序图
|
||||
|
@ -7,7 +7,7 @@ date: 2022-10-06T09:02:26+08:00
|
||||
lastmod: 2022-10-30T21:03:16+08:00
|
||||
|
||||
categories:
|
||||
- 示例
|
||||
- 示例文章
|
||||
tags:
|
||||
- toc
|
||||
- 标题
|
||||
|
@ -7,7 +7,8 @@ date: 2022-08-06T14:41:50+08:00
|
||||
lastmod: 2022-08-06T14:41:50+08:00
|
||||
|
||||
categories:
|
||||
- 示例
|
||||
- 示例文章
|
||||
- 语法
|
||||
tags:
|
||||
- 短代码
|
||||
- 语法
|
||||
|
@ -7,7 +7,8 @@ date: 2022-06-07T19:09:52+08:00
|
||||
lastmod: 2022-06-07T19:09:52+08:00
|
||||
|
||||
categories:
|
||||
- 示例
|
||||
- 示例文章
|
||||
- 语法
|
||||
tags:
|
||||
- 语法
|
||||
- 高亮
|
||||
|
@ -7,7 +7,7 @@ date: 2022-06-08T21:12:52+08:00
|
||||
lastmod: 2022-06-08T21:12:52+08:00
|
||||
|
||||
categories:
|
||||
- 示例
|
||||
- 示例文章
|
||||
tags:
|
||||
- 目录
|
||||
- 导航
|
||||
|
@ -15,40 +15,77 @@
|
||||
</div>
|
||||
<div class="post-body">
|
||||
{{ if eq .Data.Plural "categories" }}
|
||||
{{ $cats := .Site.Taxonomies.categories }}
|
||||
{{ $categories := .Site.Taxonomies.categories }}
|
||||
<div class="category-all-page">
|
||||
<div class="category-all-title">
|
||||
{{ T "CatesCounterTitle" (.Scratch.Get "catsCount") | safeHTML }}
|
||||
{{ T "Terms.categories" (.Scratch.Get "catsCount") | safeHTML }}
|
||||
</div>
|
||||
<div class="category-all">
|
||||
<ul class="category-list">
|
||||
{{ range $name, $items := $cats }}
|
||||
<li class="category-list-item">
|
||||
<a class="category-list-link" href="{{ "/categories/" | relLangURL }}{{ $name | urlize }}" data-pjax-state="">{{ .Page.Title }}</a>
|
||||
<span class="category-list-count">{{ len $items }}</span>
|
||||
</li>
|
||||
{{ $allSecondaryCats := slice }}
|
||||
{{ range .Site.Taxonomies.categories.ByCount }}
|
||||
{{ $primaryCategory := .Name }}
|
||||
{{ $primaryCount := 0 }}
|
||||
{{ $secondaryCategories := slice}}
|
||||
{{ $pages := $.Scratch.Get "pages" }}
|
||||
{{ range where $pages "Params.categories" "intersect" (slice $primaryCategory) }}
|
||||
{{ if eq (index .Params.categories 0) $primaryCategory }}
|
||||
{{ $primaryCount = add $primaryCount 1 }}
|
||||
{{/** if and (isset .Params.categories 1) (not (in $secondaryCategories (index .Params.categories 1))) **/}}
|
||||
{{ if isset .Params.categories 1 }}
|
||||
{{ if not (in $secondaryCategories (index .Params.categories 1)) }}
|
||||
{{ $secondaryCategories = $secondaryCategories | append (index .Params.categories 1) }}
|
||||
{{ $allSecondaryCats = $allSecondaryCats | append (index .Params.categories 1) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if not (in $allSecondaryCats $primaryCategory) }}
|
||||
<li class="category-list-item">
|
||||
<a class="category-list-link" href="{{ "categories/" | relURL }}{{ $primaryCategory | urlize }}">
|
||||
{{ $primaryCategory }}
|
||||
<span class="category-list-count">{{ $primaryCount }}</span>
|
||||
</a>
|
||||
</li>
|
||||
<ul class="category-children-list">
|
||||
{{ range $secondaryCategories }}
|
||||
{{ $secondaryCategory := . }}
|
||||
{{ $secondaryCount := 0 }}
|
||||
{{ range where $pages "Params.categories" "intersect" (slice $secondaryCategory) }}
|
||||
{{ if and (eq (index .Params.categories 0) $primaryCategory) (eq (index .Params.categories 1) $secondaryCategory) }}
|
||||
{{ $secondaryCount = add $secondaryCount 1 }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<li class="category-children-list-item">
|
||||
<a class="category-list-link" href="{{ "categories/" | relURL }}{{ . | urlize }}">
|
||||
{{ . }}
|
||||
<span class="category-list-count">{{ $secondaryCount }}</span>
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</ul>
|
||||
{{ end }}
|
||||
{{ if eq .Data.Plural "tags" }}
|
||||
{{ $tags := .Site.Taxonomies.tags }}
|
||||
<div class="tag-cloud">
|
||||
<div class="tag-cloud-title">
|
||||
{{ T "Terms.tags" (.Scratch.Get "tagsCount") | safeHTML }}
|
||||
{{ $tags := .Site.Taxonomies.tags }}
|
||||
<div class="tag-cloud">
|
||||
<div class="tag-cloud-title">
|
||||
{{ T "Terms.tags" (.Scratch.Get "tagsCount") | safeHTML }}
|
||||
</div>
|
||||
<div class="tag-cloud-tags">
|
||||
{{ $randNums := (seq 10) }}
|
||||
{{- range $name, $items := $tags }}
|
||||
<a class="tag-cloud-{{ index (shuffle $randNums) 0 }}" href="{{ "/tags/" | relLangURL }}{{ $name | urlize }}">{{ .Page.Title }}
|
||||
<span class="tag-list-count">
|
||||
<sup>({{ len $items }})</sup>
|
||||
</span>
|
||||
</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="tag-cloud-tags">
|
||||
{{ $randNums := (seq 10) }}
|
||||
{{- range $name, $items := $tags }}
|
||||
<a class="tag-cloud-{{ index (shuffle $randNums) 0 }}" href="{{ "/tags/" | relLangURL }}{{ $name | urlize }}">{{ .Page.Title }}
|
||||
<span class="tag-list-count">
|
||||
<sup>({{ len $items }})</sup>
|
||||
</span>
|
||||
</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -14,7 +14,9 @@
|
||||
|
||||
{{ $globalVars := newScratch }}
|
||||
|
||||
{{ $globalVars.Set "postsCount" (len (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections)) }}
|
||||
{{ $pages := (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections) }}
|
||||
{{ $globalVars.Set "pages" $pages}}
|
||||
{{ $globalVars.Set "postsCount" (len $pages)}}
|
||||
{{ $globalVars.Set "catsCount" (len .Site.Taxonomies.categories) }}
|
||||
{{ $globalVars.Set "tagsCount" (len .Site.Taxonomies.tags) }}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<span class="post-meta-item-text" title="{{ T "PostMeta.comments" }}">
|
||||
{{ print (T "PostMeta.comments") (T "Symbol.colon") }}
|
||||
</span>
|
||||
<span {{ if and .Site.Params.postMeta.comments.enable (eq .Site.Params.postMeta.comments.plugin "waline") }}class="waline-comment-count"{{end}} data-path="{{ .RelPermalink | relLangURL }}">
|
||||
<span id="comments-count" {{ if and .Site.Params.postMeta.comments.enable (eq .Site.Params.postMeta.comments.plugin "waline") }}class="waline-comment-count"{{end}} data-path="{{ .RelPermalink | relLangURL }}">
|
||||
<i class="fa fa-sync fa-spin"></i>
|
||||
</span>
|
||||
</span>
|
Loading…
Reference in New Issue
Block a user