Add a 'name in series' helper to re-use logic
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
parent
b1d4dd7a32
commit
b282843b40
|
@ -33,10 +33,10 @@
|
||||||
{{ $pages := (site.Taxonomies.series.Get .Data.Term).Pages.ByDate.Reverse }}
|
{{ $pages := (site.Taxonomies.series.Get .Data.Term).Pages.ByDate.Reverse }}
|
||||||
<nav id="SeriesNavigation" class="container">
|
<nav id="SeriesNavigation" class="container">
|
||||||
{{ with $pages.Prev page }}
|
{{ with $pages.Prev page }}
|
||||||
{{ partial "serieslink.html" (dict "direction" "previous" "link" .RelPermalink "term" $term "page" .) }}
|
{{ partial "serieslink.html" (dict "direction" "previous" "link" .RelPermalink "page" .) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ with $pages.Next page }}
|
{{ with $pages.Next page }}
|
||||||
{{ partial "serieslink.html" (dict "direction" "next" "link" .RelPermalink "term" $term "page" .) }}
|
{{ partial "serieslink.html" (dict "direction" "next" "link" .RelPermalink "page" .) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</nav>
|
</nav>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
8
layouts/partials/nameinseries.html
Normal file
8
layouts/partials/nameinseries.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{{- $term := index (.page.GetTerms "series") 0 -}}
|
||||||
|
{{- $divider := $term.Params.divider -}}
|
||||||
|
{{- if (and $divider (strings.Contains .page.Title $divider)) -}}
|
||||||
|
{{- $rest := after 1 (split .page.Title $divider) -}}
|
||||||
|
{{- .scratch.Set "name" (delimit $rest $divider) -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- .scratch.Set "name" .page.Title -}}
|
||||||
|
{{- end -}}
|
|
@ -3,13 +3,9 @@
|
||||||
{{ if eq .direction "previous" }}{{ partial "icon.html" "chevrons-left" }}{{ end }}
|
{{ if eq .direction "previous" }}{{ partial "icon.html" "chevrons-left" }}{{ end }}
|
||||||
<div class="title-subtitle">
|
<div class="title-subtitle">
|
||||||
{{ title .direction }} in Series
|
{{ title .direction }} in Series
|
||||||
{{ $divider := .term.Params.divider }}
|
{{ $scratch := newScratch -}}
|
||||||
{{ if (and $divider (strings.Contains .page.Title $divider)) }}
|
{{- partial "nameinseries.html" (dict "page" .page "scratch" $scratch) -}}
|
||||||
{{ $rest := after 1 (split .page.Title $divider) }}
|
<div class="title">{{ $scratch.Get "name" }}</div>
|
||||||
<div class="title">{{ delimit $rest $divider }}</div>
|
|
||||||
{{ else }}
|
|
||||||
<div class="title">{{ .page.Title }}</div>
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
</div>
|
||||||
{{ if eq .direction "next" }}{{ partial "icon.html" "chevrons-right" }}{{ end }}
|
{{ if eq .direction "next" }}{{ partial "icon.html" "chevrons-right" }}{{ end }}
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user