1
0
mirror of https://github.com/alanorth/hugo-theme-bootstrap4-blog.git synced 2024-11-17 17:57:04 +01:00

Add caching of last N posts in sidebar to improve performance

This commit is contained in:
mathew 2017-03-11 16:20:50 -06:00
parent 04ff763688
commit 6d027091d4
2 changed files with 10 additions and 11 deletions

View File

@ -0,0 +1,9 @@
<section class="sidebar-module">
<h4>{{ i18n "recentPosts" }}</h4>
<ol class="list-unstyled">
{{ $num_recent_posts := (index .Site.Params.sidebar "num_recent_posts" | default 5) }}
{{ range first $num_recent_posts (where .Site.RegularPages "Type" "post") }}
<li><a href="{{.RelPermalink}}">{{.Title | markdownify }}</a></li>
{{ end }}
</ol>
</section>

View File

@ -7,17 +7,7 @@
{{ end }} {{ end }}
{{ if .Site.Params.sidebar }} {{ if .Site.Params.sidebar }}
{{ $num_recent_posts := (index .Site.Params.sidebar "num_recent_posts" | default 5) }} {{ partialCached "recent.html" .}}
<section class="sidebar-module">
<h4>{{ i18n "recentPosts" }}</h4>
<ol class="list-unstyled">
{{ range first $num_recent_posts (where .Site.RegularPages "Type" "post") }}
<li><a href="{{.RelPermalink}}">{{.Title | markdownify }}</a></li>
{{ end }}
</ol>
</section>
{{ end }} {{ end }}
{{ with .Site.Menus.sidebar }} {{ with .Site.Menus.sidebar }}