mirror of
https://github.com/alanorth/hugo-theme-bootstrap4-blog.git
synced 2024-12-19 09:02:18 +01:00
Alan Orth
d214834089
By default it shows the latest five posts, but you can set this property in your config to override it: [params.sidebar] num_recent_posts = 7 Still no way to disable it, as I don't understand golang's HTML templating stuff yet. The Hugo docs are a bit confusing, but it seems like conditionals are a bit tricky because both false and 0 return a boolean false... hmm. See: https://gohugo.io/templates/go-templates/
29 lines
844 B
HTML
29 lines
844 B
HTML
<aside class="col-sm-3 offset-sm-1 blog-sidebar">
|
|
{{ if isset .Site.Params.sidebar "about" }}
|
|
<section class="sidebar-module sidebar-module-inset">
|
|
<h4>About</h4>
|
|
<p>{{ .Site.Params.sidebar.about | markdownify }}</p>
|
|
</section>
|
|
{{ end }}
|
|
|
|
{{ $num_recent_posts := (index .Site.Params.sidebar "num_recent_posts" | default 5) }}
|
|
|
|
<section class="sidebar-module">
|
|
<h4>Recent Posts</h4>
|
|
<ol class="list-unstyled">
|
|
{{ range first $num_recent_posts .Site.Pages }}
|
|
<li><a href="{{.RelPermalink}}">{{.Title}}</a></li>
|
|
{{ end }}
|
|
</ol>
|
|
</section>
|
|
|
|
<section class="sidebar-module">
|
|
<h4>Elsewhere</h4>
|
|
<ol class="list-unstyled">
|
|
<li><a href="#">GitHub</a></li>
|
|
<li><a href="#">Twitter</a></li>
|
|
<li><a href="#">Facebook</a></li>
|
|
</ol>
|
|
</section>
|
|
</aside><!-- /.blog-sidebar -->
|