Add capacity to get yearly grouping for microposts.
Adds a parameter called YearlyMicroposts which is used to either: - output the usual list of microposts if the parameter is not set or set to false; - output a list of micropost titles grouped by year (just like the posts list is) if the parameter is set and true. The default behavior is not changed and the setting needs not be defined thus not complicating the default installation.
This commit is contained in:
parent
0edc6541d0
commit
03642a1bc3
5 changed files with 45 additions and 28 deletions
|
@ -1,9 +1,7 @@
|
|||
{{ partial "site_header.html" . }}
|
||||
{{ partial "page_header.html" . }}
|
||||
|
||||
<main class="content">
|
||||
{{ partial "preview_list.html" . }}
|
||||
</main>
|
||||
{{ partial "default_list.html" . }}
|
||||
|
||||
{{ partial "page_footer.html" . }}
|
||||
{{ partial "site_footer.html" . }}
|
||||
|
|
3
layouts/partials/default_list.html
Normal file
3
layouts/partials/default_list.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<main class="content">
|
||||
{{ partial "preview_list.html" . }}
|
||||
</main>
|
25
layouts/partials/yearly_grouping.html
Normal file
25
layouts/partials/yearly_grouping.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
<main class="content">
|
||||
<article class="post-groups">
|
||||
<div class="post-group">
|
||||
{{ range .Data.Pages.GroupByDate "2006" }}
|
||||
<div class="post-group-item">
|
||||
<h3>{{ .Key }}</h3>
|
||||
<ul>
|
||||
{{ range .Pages }}
|
||||
<li>
|
||||
{{ if (not (isset .Params "externalurl")) }}
|
||||
<a rel="full-article" href="{{ .Permalink }}">{{ .Title }}</a>
|
||||
on <time datetime="{{ .Date }}" pubdate="">{{ .Date.Format "January 2" }}</time>
|
||||
{{ else }}
|
||||
<a rel="remote-article" href="{{ .Params.externalurl }}">{{ .Title }} →</a>
|
||||
on
|
||||
<a href="{{ .Permalink }}"> <time datetime="{{ .Date }}" pubdate="">{{ .Date.Format "January 2" }}</time> </a>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</article>
|
||||
</main>
|
15
layouts/section/microposts.html
Normal file
15
layouts/section/microposts.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
{{ partial "site_header.html" . }}
|
||||
{{ partial "page_header.html" . }}
|
||||
|
||||
{{ if isset .Site.Params "yearlymicroposts" | and ( .Site.Params.yearlymicroposts ) }}
|
||||
|
||||
{{ partial "yearly_grouping.html" . }}
|
||||
|
||||
{{ else }}
|
||||
|
||||
{{ partial "default_list.html" . }}
|
||||
|
||||
{{ end }}
|
||||
|
||||
{{ partial "page_footer.html" . }}
|
||||
{{ partial "site_footer.html" . }}
|
|
@ -1,31 +1,7 @@
|
|||
{{ partial "site_header.html" . }}
|
||||
{{ partial "page_header.html" . }}
|
||||
|
||||
<main class="content">
|
||||
<article class="post-groups">
|
||||
<div class="post-group">
|
||||
{{ range .Data.Pages.GroupByDate "2006" }}
|
||||
<div class="post-group-item">
|
||||
<h3>{{ .Key }}</h3>
|
||||
<ul>
|
||||
{{ range .Pages }}
|
||||
<li>
|
||||
{{ if (not (isset .Params "externalurl")) }}
|
||||
<a rel="full-article" href="{{ .Permalink }}">{{ .Title }}</a>
|
||||
on <time datetime="{{ .Date }}" pubdate="">{{ .Date.Format "January 2" }}</time>
|
||||
{{ else }}
|
||||
<a rel="remote-article" href="{{ .Params.externalurl }}">{{ .Title }} →</a>
|
||||
on
|
||||
<a href="{{ .Permalink }}"><time datetime="{{ .Date }}" pubdate="">{{ .Date.Format "January 2" }}</time></a>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</article>
|
||||
</main>
|
||||
{{ partial "yearly_grouping.html" . }}
|
||||
|
||||
{{ partial "page_footer.html" . }}
|
||||
{{ partial "site_footer.html" . }}
|
||||
|
|
Loading…
Add table
Reference in a new issue