Merge pull request #13 from CaiJimmy/custom-taxonomy-permalink

feat(article): add support for custom taxonomy link
This commit is contained in:
Jimmy Cai 2020-09-18 20:06:42 +02:00 committed by GitHub
commit 3a003eadca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 16 deletions

View file

@ -1,16 +1,18 @@
{{ $image := partialCached "helper/image" (dict "Context" . "Type" "article") .RelPermalink "article" }}
{{ $context := . }}
{{- $context := . -}}
{{- $categories := .Params.categories -}}
<div class="article-details">
{{ with $categories := .Params.categories }}
{{ if $categories }}
<header class="article-category">
{{ range $categories }}
{{ range $category := $categories }}
{{ $term := $.Site.GetPage (printf "/categories/%s" $category) }}
{{ if and $image.exists $image.resource }}
{{- $imageRaw := $image.resource | resources.Fingerprint "md5" -}}
{{- $20x := $imageRaw.Fill "20x20 smart" -}}
<a href="{{ printf `categories/%s` (. | urlize) | relLangURL }}" class="color-tag"
data-image="{{ $20x.RelPermalink }}" data-key="{{ $context.Slug }}" data-hash="{{ $imageRaw.Data.Integrity }}">{{ . | humanize }}</a>
<a href="{{ $term.Permalink }}" class="color-tag"
data-image="{{ $20x.RelPermalink }}" data-key="{{ $context.Slug }}" data-hash="{{ $imageRaw.Data.Integrity }}">{{ $term.Title | humanize }}</a>
{{ else }}
<a href="{{ printf `categories/%s` (. | urlize) | relLangURL }}">{{ . | humanize }}</a>
<a href="{{ $term.Permalink }}">{{ $term.Title | humanize }}</a>
{{ end }}
{{ end }}
</header>

View file

@ -1,11 +1,5 @@
<footer class="article-footer">
{{ with $tags := .Params.Tags }}
<section class="article-tags">
{{ range $tags }}
<a href="{{ printf `tags/%s` (. | urlize) | relLangURL }}">{{ . | humanize }}</a>
{{ end }}
</section>
{{ end }}
{{ partial "article/components/tags" . }}
{{ if and (.Site.Params.article.license.enabled) (not (eq .Params.license false)) }}
<section class="article-copyright">

View file

@ -0,0 +1,10 @@
{{- $tags := .Params.Tags -}}
{{ if $tags }}
<section class="article-tags">
{{ range $tag := $tags }}
{{ with $.Site.GetPage (printf "/tags/%s" $tag) }}
<a href="{{ .Permalink }}">{{ .Title | humanize }}</a>
{{ end }}
{{ end }}
</section>
{{ end }}

View file

@ -8,9 +8,10 @@
<div class="tagCloud-tags">
{{ range first .Site.Params.widgets.tagCloud.limit $tags }}
<a href="{{ printf `tags/%s` (.Term | urlize) | relLangURL }}" class="font_size_{{ .Count }}">
{{ .Term | humanize }}
</a>
{{ $term := $.Site.GetPage (printf "/tags/%s" .Term) }}
<a href="{{ $term.Permalink }}" class="font_size_{{ .Count }}">
{{ $term.Title | humanize }}
</a>
{{ end }}
</div>
</section>