Skip to content

Commit c827919

Browse files
committed
Show category in recent posts list
1 parent ecc7ab5 commit c827919

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

layouts/_default/baseof.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{{ if not .IsHome }}
2020
<aside class="sidebar">
2121
{{ if .IsPage }}
22-
<h3><a href="{{ .FirstSection.Permalink }}">{{ .FirstSection.Title }}</a></h3>
22+
<h3><a href="{{ .FirstSection.Permalink }}">{{ .FirstSection.Title }} (recent)</a></h3>
2323
<ul>
2424
{{ range first 5 .FirstSection.Pages.ByDate.Reverse }}
2525
<li><a href="{{ .Permalink }}"{{ if eq $.RelPermalink .RelPermalink }} class="active"{{ end }}>{{ .Title }}</a></li>
@@ -29,7 +29,7 @@ <h3><a href="{{ .FirstSection.Permalink }}">{{ .FirstSection.Title }}</a></h3>
2929
{{ end }}
3030
</ul>
3131
{{ else }}
32-
<h3>{{ .Title }}</h3>
32+
<h3>{{ .Title }} (recent)</h3>
3333
<ul>
3434
{{ range first 5 .Pages.ByDate.Reverse }}
3535
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>

layouts/_default/list.html

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,28 @@ <h2>Recent Posts</h2>
99
<li>
1010
<span class="date">{{ .Date.Format "2006-01-02" }}</span>
1111
<a href="{{ .Permalink }}">{{ .Title }}</a>
12+
<span class="tag">{{ .FirstSection.Title }}</span>
1213
</li>
1314
{{ end }}
1415
</ul>
1516

1617
<h2>Topics</h2>
17-
<ul class="post-list">
18-
{{ range .Site.Sections }}
19-
<li>
20-
<a href="{{ .Permalink }}">{{ .Title }}</a>
21-
{{ with .Params.description }}<span class="date"> — {{ . }}</span>{{ end }}
22-
</li>
18+
{{ range .Site.Sections }}
19+
<h3><a href="{{ .Permalink }}">{{ .Title }}</a>{{ with .Params.description }} <span class="date">— {{ . }}</span>{{ end }}</h3>
20+
{{ if .Pages }}
21+
<ul class="post-list">
22+
{{ range first 5 .Pages.ByDate.Reverse }}
23+
<li>
24+
<span class="date">{{ .Date.Format "2006-01-02" }}</span>
25+
<a href="{{ .Permalink }}">{{ .Title }}</a>
26+
</li>
27+
{{ end }}
28+
{{ if gt (len .Pages) 5 }}
29+
<li><a href="{{ .Permalink }}">See all →</a></li>
30+
{{ end }}
31+
</ul>
2332
{{ end }}
24-
</ul>
33+
{{ end }}
2534
{{ else }}
2635
<nav class="breadcrumb">
2736
<a href="{{ .Site.BaseURL }}">All Posts</a>

0 commit comments

Comments
 (0)