mirror of
https://github.com/alanorth/hugo-theme-bootstrap4-blog.git
synced 2024-12-25 03:34:29 +01:00
Use .Site.Params.mainSections instead of hard coding "post" type
Hugo 0.32 or so added the quasi-magical .Site.Params.mainSections slice that returns a range over the section that has the most number of pages. This way we don't need to hard code the "post" type, and instead simply use the pages that the user has created. Hugo's quickstart, for example, recommends users create "posts", which currently doesn't work with this theme! Closes #89
This commit is contained in:
parent
99acad59bc
commit
1655b876a8
@ -37,17 +37,10 @@
|
||||
<nav class="nav blog-nav">
|
||||
<a class="nav-link {{ if .IsHome }}active{{ end }}" href="{{ .Site.BaseURL | absLangURL }}">{{ i18n "home" }}</a>
|
||||
{{- $currentURL := .URL | absLangURL -}}
|
||||
{{ if .Site.Params.custom_navbar }}
|
||||
{{ range .Site.Menus.navbar }}
|
||||
{{ $menuURL := .URL | absLangURL }}
|
||||
<a class="nav-link{{ if eq $menuURL $currentURL }} active{{ end }}" href="{{.URL | absURL }}">{{ .Name }}</a>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ range where .Site.RegularPages "Type" "!=" "post" }}
|
||||
{{ $permalinkURL := .Permalink | absLangURL }}
|
||||
<a class="nav-link{{ if eq $permalinkURL $currentURL }} active{{ end }}" href="{{ .Permalink }}">{{ .Title }}</a>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -30,7 +30,7 @@
|
||||
{{ define "main" }}
|
||||
|
||||
{{ $truncate := default true .Site.Params.truncate }}
|
||||
{{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}
|
||||
{{ $paginator := .Paginate (where .Site.Pages "Section" "in" .Site.Params.mainSections) }}
|
||||
{{ range $paginator.Pages }}
|
||||
{{ if $truncate }}
|
||||
{{ .Render "summary" }}
|
||||
|
@ -2,7 +2,7 @@
|
||||
<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") }}
|
||||
{{ range first $num_recent_posts (where .Site.Pages "Section" "in" .Site.Params.mainSections) }}
|
||||
<li><a href="{{.RelPermalink}}">{{.Title | markdownify }}</a></li>
|
||||
{{ end }}
|
||||
</ol>
|
||||
|
Loading…
Reference in New Issue
Block a user