[FEATURE]: Add Series Taxonomy (#123)

* feat: add basic series taxonomy

* feat(series-taxonomy) add support for basic intro

* feat(series-taxonomy) add support for summary and meta

* feat(series-taxonomy): add i18n and docs
This commit is contained in:
PCloud 2021-07-04 11:42:28 +08:00 committed by GitHub
parent ee866f94c1
commit c74187e8cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 232 additions and 27 deletions

View File

@ -9,6 +9,7 @@ description: ""
tags: []
categories: []
series: []
hiddenFromHomePage: false
hiddenFromSearch: false

View File

@ -63,7 +63,7 @@
padding-top: 0;
}
.categories-card, .author-card {
.categories-card, .author-card, .series-card {
.card-item {
width: 100%;
}

View File

@ -33,3 +33,4 @@
@import "_archive";
@import "_home";
@import "_404";
@import "_taxonomy";

View File

@ -0,0 +1,16 @@
.introduction blockquote {
display: block;
border-left: .5rem solid $blockquote-color;
background-color: rgba($blockquote-color, .2);
padding: .25rem .75rem;
margin: 1rem 0;
[theme=dark] & {
border-left-color: $blockquote-color-dark;
background-color: rgba($blockquote-color-dark, .2);
}
[theme=black] & {
border-left-color: $blockquote-color-black;
background-color: rgba($blockquote-color-black, .2);
}
}

View File

@ -1,4 +1,4 @@
.categories-card, .author-card {
.categories-card, .author-card, .series-card {
margin: 0 auto;
margin-top: 3rem;
display: flex;

View File

@ -67,6 +67,14 @@ enableEmoji = true
url = "/categories/"
title = ""
weight = 3
[[languages.en.menu.main]]
identifier = "series"
pre = ""
post = ""
name = "Series"
url = "/series/"
title = ""
weight = 4
[[languages.en.menu.main]]
identifier = "authors"
pre = ""
@ -74,7 +82,7 @@ enableEmoji = true
name = "Authors"
url = "/authors/"
title = ""
weight = 4
weight = 5
[[languages.en.menu.main]]
identifier = "documentation"
pre = ""
@ -82,7 +90,7 @@ enableEmoji = true
name = "Docs"
url = "/categories/documentation/"
title = ""
weight = 5
weight = 6
[[languages.en.menu.main]]
identifier = "about"
pre = ""
@ -90,7 +98,7 @@ enableEmoji = true
name = "About"
url = "/about/"
title = ""
weight = 6
weight = 7
[[languages.en.menu.main]]
identifier = "github"
pre = "<i class='fab fa-github fa-fw'></i>"
@ -98,7 +106,7 @@ enableEmoji = true
name = ""
url = "https://github.com/HEIGE-PCloud/DoIt"
title = "GitHub"
weight = 7
weight = 8
[languages.en.params]
# site description
description = "About DoIt Theme"
@ -286,6 +294,14 @@ enableEmoji = true
url = "/categories/"
title = ""
weight = 3
[[languages.zh-cn.menu.main]]
identifier = "series"
pre = ""
post = ""
name = "系列"
url = "/series/"
title = ""
weight = 4
[[languages.zh-cn.menu.main]]
identifier = "authors"
pre = ""
@ -293,14 +309,14 @@ enableEmoji = true
name = "作者"
url = "/authors/"
title = ""
weight = 4
weight = 5
[[languages.zh-cn.menu.main]]
identifier = "documentation"
pre = ""
name = "文档"
url = "/categories/documentation/"
title = ""
weight = 5
weight = 6
[[languages.zh-cn.menu.main]]
identifier = "about"
pre = ""
@ -308,7 +324,7 @@ enableEmoji = true
name = "关于"
url = "/about/"
title = ""
weight = 6
weight = 7
[[languages.zh-cn.menu.main]]
identifier = "github"
pre = "<i class='fab fa-github fa-fw'></i>"
@ -316,7 +332,7 @@ enableEmoji = true
name = ""
url = "https://github.com/HEIGE-PCloud/DoIt"
title = "GitHub"
weight = 7
weight = 8
[languages.zh-cn.params]
# 网站描述
description = "关于 DoIt 主题"
@ -1205,7 +1221,10 @@ enableEmoji = true
taxonomy = ["HTML", "RSS"]
taxonomyTerm = ["HTML"]
# Options for taxonomies
# 用于分类的设置
[taxonomies]
author = "authors"
category = "categories"
tag = "tags"
series = "series"

View File

@ -0,0 +1,15 @@
---
title: "Series Taxonomy Test"
date: 2021-07-03T22:15:26+08:00
lastmod: 2021-07-03T22:15:26+08:00
draft: false
description: "Series Taxonomy Test"
categories: [Tests]
series: [Test pages]
hiddenFromHomePage: true
hiddenFromSearch: true
---
<!--more-->
[Series Taxonomy](/series)

View File

@ -0,0 +1,15 @@
---
title: "系列分类测试"
date: 2021-07-03T22:15:26+08:00
lastmod: 2021-07-03T22:15:26+08:00
draft: false
description: "系列分类测试"
categories: [Tests]
series: [Test pages]
hiddenFromHomePage: true
hiddenFromSearch: true
---
<!--more-->
[系列分类](/zh-cn/series)

View File

@ -764,6 +764,12 @@ Please open the code block below to view the complete sample configuration :(far
taxonomy = ["HTML", "RSS"]
taxonomyTerm = ["HTML"]
# Options for taxonomies
[taxonomies]
author = "authors"
category = "categories"
tag = "tags"
series = "series"
```
{{< admonition >}}

View File

@ -768,6 +768,12 @@ hugo
taxonomy = ["HTML", "RSS"]
taxonomyTerm = ["HTML"]
# 用于分类的设置
[taxonomies]
author = "authors"
category = "categories"
tag = "tags"
series = "series"
```
{{< admonition >}}

View File

@ -109,6 +109,7 @@ images: []
tags: []
categories: []
series: []
featuredImage: ""
featuredImagePreview: ""
@ -169,6 +170,7 @@ seo:
* **tags**: the tags for the content.
* **categories**: the categories for the content.
* **series**: {{< version 0.2.12 >}} the series for the content.
* **featuredImage**: the featured image for the content.
* **featuredImagePreview**: the featured image for the content preview in the home page.

View File

@ -108,6 +108,7 @@ images: []
tags: []
categories: []
series: []
featuredImage: ""
featuredImagePreview: ""
@ -168,6 +169,7 @@ seo:
* **tags**: 文章的标签.
* **categories**: 文章所属的类别.
* **series**: {{< version 0.2.12 >}} 文章所属的系列.
* **featuredImage**: 文章的特色图片.
* **featuredImagePreview**: 用在主页预览的文章特色图片.

View File

@ -0,0 +1,3 @@
---
title: Series
---

View File

@ -0,0 +1,3 @@
---
title: 系列
---

View File

@ -0,0 +1,4 @@
---
title: Test Pages
introduction: These pages are used to test and debug the DoIt theme.
---

View File

@ -0,0 +1,4 @@
---
title: 测试页面系列
introduction: 这些页面用于测试与调试 DoIt 主题。
---

View File

@ -29,6 +29,9 @@ other = "Category"
[categories]
other = "Categories"
[series]
other = "Series"
# === Taxonomy ===
# === Pagination ===
@ -116,8 +119,18 @@ other = "Contents"
[publishedOnDate]
other = "published on {{ .Date }}"
[includedIn]
other = "included in "
[includedInAnd]
other = "and"
[includedInCategories]
other = "included in {{ .Categories }}"
one = "category {{ .Categories }}"
other = "categories {{ .Categories }}"
[includedInSeries]
other = "series {{ .Series }}"
[wordCount]
one = "One word"

View File

@ -30,6 +30,9 @@ other = "分类"
[categories]
other = "分类"
[series]
other = "系列"
# === Taxonomy ===
# === Pagination ===
@ -123,8 +126,17 @@ other = "目录"
[publishedOnDate]
other = "发布于 {{ .Date }}"
[includedIn]
other = "收录于 "
[includedInAnd]
other = "和"
[includedInCategories]
other = "收录于 {{ .Categories }}"
other = "类别 {{ .Categories }}"
[includedInSeries]
other = "系列 {{ .Series }}"
[wordCount]
other = "约 {{ .Count }} 字"

View File

@ -45,16 +45,39 @@
</span>
{{- end -}}
{{- $categories := slice -}}
{{- range .Params.categories -}}
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
{{- $categories = $categories | append (printf `<a href="%v"><i class="far fa-folder fa-fw"></i>%v</a>` $category.RelPermalink $category.Title) -}}
{{- end -}}
{{- with delimit $categories "&nbsp;" -}}
&nbsp;<span class="post-category">
{{- dict "Categories" . | T "includedInCategories" | safeHTML -}}
</span>
{{- end -}}
{{- with (or (.Params.categories) (.Params.series)) -}}
&nbsp;<span class="post-category">
{{- T "includedIn" | safeHTML -}}
</span>
{{- end -}}
{{- $categories := slice -}}
{{- range .Params.categories -}}
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
{{- $categories = $categories | append (printf `<a href="%v"><i class="far fa-folder fa-fw"></i>%v</a>` $category.RelPermalink $category.Title) -}}
{{- end -}}
{{- with delimit $categories "&nbsp;" -}}
&nbsp;<span class="post-category">
{{- dict "Categories" . "Count" (len $categories) | T "includedInCategories" | safeHTML -}}
</span>
{{- end -}}
{{- with (and (.Params.categories) (.Params.series)) -}}
&nbsp;<span class="post-category">
{{- T "includedInAnd" | safeHTML -}}
</span>
{{- end -}}
{{- $series := slice -}}
{{- range .Params.series -}}
{{- $singleSeries := partialCached "function/path.html" . . | printf "/series/%v" | $.Site.GetPage -}}
{{- $series = $series | append (printf `<a href="%v"><i class="far fa-list-alt fa-fw"></i>%v</a>` $singleSeries.RelPermalink $singleSeries.Title) -}}
{{- end -}}
{{- with delimit $series "&nbsp;" -}}
&nbsp;<span class="post-series">
{{- dict "Series" . | T "includedInSeries" | safeHTML -}}
</span>
{{- end -}}
</div>
{{- /* Summary content */ -}}

View File

@ -11,7 +11,7 @@
{{- if $.Site.Params.search.absoluteURL -}}
{{- $uri = .Permalink -}}
{{- end -}}
{{- $meta := dict "uri" $uri "title" .Title "tags" .Params.tags "categories" .Params.categories -}}
{{- $meta := dict "uri" $uri "title" .Title "tags" .Params.tags "categories" .Params.categories "series" .Params.series -}}
{{- $meta = $.Site.Params.dateFormat | default "2006-01-02" | .PublishDate.Format | dict "date" | merge $meta -}}
{{- with .Description -}}
{{- $index = $index | append (dict "content" . "objectID" $uri | merge $meta) -}}

View File

@ -52,7 +52,12 @@
<span class="post-author">
{{- partial "meta/author.html" . }}
</span>
{{- with (or (.Params.categories) (.Params.series)) -}}
&nbsp;<span class="post-category">
{{- T "includedIn" | safeHTML -}}
</span>
{{- end -}}
{{- $categories := slice -}}
{{- range .Params.categories -}}
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
@ -60,7 +65,24 @@
{{- end -}}
{{- with delimit $categories "&nbsp;" -}}
&nbsp;<span class="post-category">
{{- dict "Categories" . | T "includedInCategories" | safeHTML -}}
{{- dict "Categories" . "Count" (len $categories) | T "includedInCategories" | safeHTML -}}
</span>
{{- end -}}
{{- with (and (.Params.categories) (.Params.series)) -}}
&nbsp;<span class="post-category">
{{- T "includedInAnd" | safeHTML -}}
</span>
{{- end -}}
{{- $series := slice -}}
{{- range .Params.series -}}
{{- $singleSeries := partialCached "function/path.html" . . | printf "/series/%v" | $.Site.GetPage -}}
{{- $series = $series | append (printf `<a href="%v"><i class="far fa-list-alt fa-fw"></i>%v</a>` $singleSeries.RelPermalink $singleSeries.Title) -}}
{{- end -}}
{{- with delimit $series "&nbsp;" -}}
&nbsp;<span class="post-series">
{{- dict "Series" . | T "includedInSeries" | safeHTML -}}
</span>
{{- end -}}
</div>

View File

@ -25,7 +25,12 @@
{{- printf "%v - %v" (T $taxonomy | default $taxonomy) .Title -}}
{{- end -}}
</h2>
{{- /* Introduction*/ -}}
{{- with .Params.introduction -}}
<div class="introduction">
<blockquote>{{- . -}}</blockquote>
</div>
{{- end -}}
{{- /* Paginate */ -}}
{{- if .Pages -}}
{{- $pages := .Pages.GroupByDate "2006" -}}

View File

@ -45,6 +45,39 @@
{{- end -}}
</div>
{{- /* Series Page */ -}}
{{- else if eq $taxonomies "series" -}}
{{- $terms := .Data.Terms.ByCount -}}
<div class="series-card">
{{- range $terms -}}
{{- $term := .Term -}}
{{- $pages := .Pages -}}
{{- with $.Site.GetPage "taxonomy" (printf "%v/%v" $type $term) -}}
<div class="card-item">
<div class="card-item-wrapper">
<h3 class="card-item-title">
<a href="{{ .RelPermalink }}">
<i class="far fa-folder fa-fw"></i>&nbsp;{{ .Page.Title }}
</a>
</h3>
{{- range first 5 $pages -}}
<article class="archive-item">
<a href="{{ .RelPermalink }}" class="archive-item-link">
{{- .Title -}}
</a>
</article>
{{- end -}}
{{- if gt (len $pages) 5 -}}
<span class="more-post">
<a href="{{ .RelPermalink }}" class="more-single-link">{{ T "more" }} >></a>
</span>
{{- end -}}
</div>
</div>
{{- end -}}
{{- end -}}
</div>
{{- /* Author Page */ -}}
{{- else if eq $taxonomies "authors" -}}
{{- $terms := .Data.Terms.Alphabetical -}}