Skip to content

Commit

Permalink
feat: use Page.GetTerms
Browse files Browse the repository at this point in the history
closes #67
  • Loading branch information
reuixiy committed Feb 20, 2020
1 parent 299c218 commit 110064a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 41 deletions.
8 changes: 2 additions & 6 deletions layouts/index.sectionsatom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,8 @@
{{ with $.Site.Taxonomies }}
{{ range $taxonomy, $terms := . }}
{{ with $page.Param $taxonomy }}
{{ range $index, $term := . }}
{{ $url := urls.Parse ($term | urlize) }}
{{ $path := $url.Path }}
{{ with $.Site.GetPage (printf "/%s/%s" $taxonomy $path) }}
<category scheme="{{ .Permalink }}" term="{{ .Title | default $term }}" label="{{ .Title | default $term }}" />
{{ end }}
{{ range ($page.GetTerms $taxonomy) }}
<category scheme="{{ .Permalink }}" term="{{ .Title }}" label="{{ .Title }}" />
{{ end }}
{{ end }}
{{ end }}
Expand Down
8 changes: 2 additions & 6 deletions layouts/index.sectionsrss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,8 @@
{{ with $.Site.Taxonomies }}
{{ range $taxonomy, $terms := . }}
{{ with $page.Param $taxonomy }}
{{ range $index, $term := . }}
{{ $url := urls.Parse ($term | urlize) }}
{{ $path := $url.Path }}
{{ with $.Site.GetPage (printf "/%s/%s" $taxonomy $path) }}
<category domain="{{ .Permalink }}">{{ .Title | default $term }}</category>
{{ end }}
{{ range ($page.GetTerms $taxonomy) }}
<category scheme="{{ .Permalink }}" term="{{ .Title }}" label="{{ .Title }}" />
{{ end }}
{{ end }}
{{ end }}
Expand Down
20 changes: 6 additions & 14 deletions layouts/partials/components/minimal-footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
{{ with .Params.tags }}
{{ $length := sub (len .) 1 }}
<div class="post-tag">
{{- range $index, $tag := . -}}
{{- $url := urls.Parse ($tag | urlize) -}}
{{- $path := $url.Path -}}
{{- with $.Site.GetPage (printf `/tags/%s` $path) -}}
<a href="{{ .RelPermalink }}" rel="tag" class="post-tag-link">#{{ .Slug | default .LinkTitle | default $tag | lower | anchorize }}</a>
{{- if lt $index $length -}}
{{- print " " -}}
{{- end -}}
{{- range $index, $tag := ($.GetTerms "tags") -}}
<a href="{{ .RelPermalink }}" rel="tag" class="post-tag-link">#{{ .Slug | default .LinkTitle | default $tag | lower | anchorize }}</a>
{{- if lt $index $length -}}
{{- print " " -}}
{{- end -}}
{{- end -}}
</div>
Expand Down Expand Up @@ -103,18 +99,14 @@
{{- end -}}
{{ else }}
{{ $length := sub (len .) 1 }}
{{- range $index, $category := . -}}
{{- range $index, $category := ($.GetTerms "categories") -}}
{{- if lt $index $length -}}
{{- $.Scratch.Set "delimiter" ($.Site.Params.categoryDelimiter | default "/") -}}
{{- else -}}
{{- $.Scratch.Set "delimiter" "" -}}
{{- end -}}
{{- $delimiter := ($.Scratch.Get "delimiter") -}}
{{- $url := urls.Parse ($category | urlize) -}}
{{- $path := $url.Path -}}
{{- with $.Site.GetPage (printf `/categories/%s` $path) -}}
{{- printf `<a href="%s" class="post-category-link">%s</a>%s` .RelPermalink (.Slug | default .LinkTitle | default $category | lower | anchorize) $delimiter | safeHTML -}}
{{- end -}}
{{- printf `<a href="%s" class="post-category-link">%s</a>%s` .RelPermalink (.Slug | default .LinkTitle | default $category | lower | anchorize) $delimiter | safeHTML -}}
{{- end -}}
{{ end }}
</div>
Expand Down
8 changes: 2 additions & 6 deletions layouts/partials/components/post-meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,14 @@
{{ $length := sub (len .) 1 }}
<span class="post-meta-item category">
{{- printf `%s&nbsp;` $icon | safeHTML -}}
{{- range $index, $category := . -}}
{{- $url := urls.Parse ($category | urlize) -}}
{{- $path := $url.Path -}}
{{- range $index, $category := ($Deliver.GetTerms "categories") -}}
{{- if lt $index $length -}}
{{- $Deliver.Scratch.Set "delimiter" ($Deliver.Site.Params.categoryDelimiter | default "/") -}}
{{- else -}}
{{- $Deliver.Scratch.Set "delimiter" "" -}}
{{- end -}}
{{- $delimiter := ($Deliver.Scratch.Get "delimiter") -}}
{{- with $Deliver.Site.GetPage (printf `/categories/%s` $path) -}}
{{- printf `<a href="%s" class="category-link">%s</a>%s` .RelPermalink (.LinkTitle | default $category) $delimiter | safeHTML -}}
{{- end -}}
{{- printf `<a href="%s" class="category-link">%s</a>%s` .RelPermalink (.LinkTitle | default $category) $delimiter | safeHTML -}}
{{- end -}}
</span>
{{ end }}
Expand Down
11 changes: 3 additions & 8 deletions layouts/partials/components/post-tags.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
{{ if .Site.Params.enablePostTags }}
{{ with .Params.tags }}
<div class="post-tags">
{{ range . }}
{{ $tag := . }}
{{ $url := urls.Parse (. | urlize) }}
{{ $path := $url.Path }}
{{ with $.Site.GetPage (printf `/tags/%s` $path) }}
{{ $icon := (replace (index $.Site.Data.SVG $.Site.Params.postTagsIcon) "icon" "icon tag-icon") }}
<a href="{{ .RelPermalink }}" rel="tag" class="post-tags-link">{{ $icon | safeHTML }}{{ .LinkTitle | default $tag }}</a>
{{ end }}
{{ range ($.GetTerms "tags") }}
{{ $icon := (replace (index $.Site.Data.SVG $.Site.Params.postTagsIcon) "icon" "icon tag-icon") }}
<a href="{{ .RelPermalink }}" rel="tag" class="post-tags-link">{{ $icon | safeHTML }}{{ .LinkTitle }}</a>
{{ end }}
</div>
{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "MemE is a powerful and highly customizable GoHugo theme for perso
homepage = "https://github.com/reuixiy/hugo-theme-meme/"
tags = ["Blog", "Minimal", "Clean", "Typography", "Multilingual"]
features = ["Dark Mode", "InstantClick", "KaTeX", "JSON-LD", "Drop Cap", "PWA", "TOC"]
min_version = "0.62.2"
min_version = "0.65.0"

[author]
name = "reuixiy"
Expand Down

0 comments on commit 110064a

Please sign in to comment.