Implement collapsing consecutive posts in a series
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
parent
dde3fb61ae
commit
8b8d3c7fd0
|
@ -249,6 +249,20 @@ ul.post-list {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-bottom: 0.6rem;
|
margin-bottom: 0.6rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.series-link {
|
||||||
|
margin-top: 1rem;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
border-top: $standard-border;
|
||||||
|
padding-top: 1rem;
|
||||||
|
|
||||||
|
.feather {
|
||||||
|
fill: none;
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
margin-right: 0.5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.katex-html {
|
.katex-html {
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
one = "about one minute to read"
|
one = "about one minute to read"
|
||||||
other = "about {{ .Count }} minutes to read"
|
other = "about {{ .Count }} minutes to read"
|
||||||
|
|
||||||
|
[latestInSeries]
|
||||||
|
other = "Latest in series:"
|
||||||
|
|
||||||
[recentPosts]
|
[recentPosts]
|
||||||
other = "Recent posts"
|
other = "Recent posts"
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
|
|
||||||
{{ i18n "recentPosts" }}:
|
{{ i18n "recentPosts" }}:
|
||||||
|
{{ partial "uniquebyseries.html" (dict "scratch" .Scratch) }}
|
||||||
<ul class="post-list">
|
<ul class="post-list">
|
||||||
{{ range first 10 (where (where .Site.Pages.ByDate.Reverse "Section" "blog") ".Kind" "!=" "section") }}
|
{{ range first 10 (.Scratch.Get "pages") }}
|
||||||
{{ partial "post.html" (dict "page" .) }}
|
{{ partial "post.html" (dict "page" . "linkSeries" true) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -15,4 +15,13 @@
|
||||||
</p>
|
</p>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<p class="post-preview">{{ .page.Summary }} {{ if .page.Truncated }}...{{ end }}</p>
|
<p class="post-preview">{{ .page.Summary }} {{ if .page.Truncated }}...{{ end }}</p>
|
||||||
|
{{- if .linkSeries -}}
|
||||||
|
{{- $term := index (.page.GetTerms "series") 0 -}}
|
||||||
|
{{- with $term -}}
|
||||||
|
<p class="series-link">
|
||||||
|
{{- partial "icon.html" "corner-down-right" -}}
|
||||||
|
{{- i18n "latestInSeries" }} <a href="{{ $term.Permalink }}">{{ $term.Title }}</a>
|
||||||
|
</p>
|
||||||
|
{{- end -}}
|
||||||
|
{{- end }}
|
||||||
</li>
|
</li>
|
||||||
|
|
14
layouts/partials/uniquebyseries.html
Normal file
14
layouts/partials/uniquebyseries.html
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{{- $scratch := .scratch -}}
|
||||||
|
{{- $scratch.Set "pages" slice -}}
|
||||||
|
{{- $tmpScratch := newScratch -}}
|
||||||
|
{{- range $post := (where (where site.Pages.ByDate.Reverse "Section" "blog") ".Kind" "!=" "section") -}}
|
||||||
|
{{- $term := index ($post.GetTerms "series") 0 -}}
|
||||||
|
{{- if $term -}}
|
||||||
|
{{- if not ($tmpScratch.Get $term.Permalink) -}}
|
||||||
|
{{- $tmpScratch.Set $term.Permalink true -}}
|
||||||
|
{{- $scratch.Add "pages" $post -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $scratch.Add "pages" $post -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
Loading…
Reference in New Issue
Block a user