diff options
author | Dillon ZENG <dillonzq@outlook.com> | 2019-08-04 16:53:35 +0300 |
---|---|---|
committer | Dillon ZENG <dillonzq@outlook.com> | 2019-08-04 16:53:35 +0300 |
commit | c67a2a86a187923b87ad56ffe523b29079206656 (patch) | |
tree | 254cfbbbafe71dd11bc64745aea78d0270e9b350 /layouts/taxonomy | |
parent | 1e709b5ba48256988de2140ffb2a84ca956b5887 (diff) |
feat: impove i18n and clean code
Diffstat (limited to 'layouts/taxonomy')
-rw-r--r-- | layouts/taxonomy/list.html | 28 | ||||
-rw-r--r-- | layouts/taxonomy/terms.html | 61 |
2 files changed, 89 insertions, 0 deletions
diff --git a/layouts/taxonomy/list.html b/layouts/taxonomy/list.html new file mode 100644 index 0000000..6449d40 --- /dev/null +++ b/layouts/taxonomy/list.html @@ -0,0 +1,28 @@ +{{ define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end }} + +{{ define "content" }} + {{ $taxonomy := .Data.Singular }} + {{ $taxonomyName := $taxonomy }} + {{ if eq $taxonomy "tag"}} + {{ $taxonomyName = (T "tag") }} + {{ else if eq $taxonomy "category"}} + {{ $taxonomyName = (T "category") }} + {{ end }} + <div class="post-warp archive"> + <h2 class="post-title" style="text-align:right;padding-bottom:2em"> + {{- printf "%s - %s" $taxonomyName .Title -}} + </h2> + {{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }} + <h3>{{ .Key }}</h3> + {{ range .Pages }} + <article class="archive-item"> + <a href="{{ .RelPermalink }}" class="archive-item-link">{{ .Title }}</a> + <span class="archive-item-date"> + {{ .Date.Format (.Site.Params.dateFormatToUse | default "01-02") }} + </span> + </article> + {{ end }} + {{ end }} + {{ partial "paginator.html" . }} + </div> +{{end }} diff --git a/layouts/taxonomy/terms.html b/layouts/taxonomy/terms.html new file mode 100644 index 0000000..3bed3fc --- /dev/null +++ b/layouts/taxonomy/terms.html @@ -0,0 +1,61 @@ +{{ define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end }} + +{{ define "content" }} + {{ $taxonomy := .Data.Singular }} + {{ $taxonomysName := $taxonomy }} + {{ if eq $taxonomy "tag"}} + {{ $taxonomysName = (T "tags") }} + {{ else if eq $taxonomy "category"}} + {{ $taxonomysName = (T "categories") }} + {{ end }} + + {{ $terms := .Data.Terms.ByCount }} + {{ $length := len $terms }} + {{ $type := .Type }} + + <div class="post-warp {{.Data.Plural}}"> + <h2 class="post-title" style="text-align:right;padding-bottom:2em"> + {{- printf "- %s -" $taxonomysName -}} + </h2> + + <!-- Categories Page --> + {{ if eq $taxonomy "category" }} + <div class="categories-card"> + {{ range $terms }} + {{ $term := .Term }} + {{ $pages := .Pages }} + {{ with $.Site.GetPage "taxonomy" (printf "%s/%s" $type $term) }} + <div class="card-item"> + <div class="categories"> + <a href="{{ .Permalink }}"> + <h3> <i class="iconfont icon-folder" style="padding-right: 3px"></i> {{ $term | humanize}} </h3> + </a> + {{ range first 5 $pages }} + <article class="archive-item"> + <a href="{{ .Permalink }}" class="archive-item-link">{{ .Title }}</a> + </article> + {{ end }} + {{ if gt (len $pages) 5 }} + <span class="more-post"> + <a href="{{ .Permalink }}" class="more-post-link">{{ T "More" }} >></a> + </span> + {{ end }} + </div> + </div> + {{ end }} + {{ end }} + </div> + + <!-- Tag Cloud Page --> + {{ else if eq $taxonomy "tag" }} + <div class="tag-cloud-tags"> + {{ range $.Site.Taxonomies.tags.ByCount }} + {{ if .Name }} + <a href="/tags/{{ .Name | urlize}}/"> {{ .Name }} <small>({{ .Count }})</small></a> + {{ end }} + {{end}} + </div> + + {{ end }} + </div> +{{end }} |