Single and List views not apply to all page types

Single and List views not apply to all page types. Previously list view
would only apply to posts. With this change, a new content folder named
"foo" will now list all content within the "foo" folder. In addition,
the Single layout is now generalized and applies to all types of
content.
This commit is contained in:
Michael Romero 2017-04-24 21:17:24 -07:00
parent be5a5c2ac7
commit 0d2ddebdd9
4 changed files with 51 additions and 57 deletions

View File

@ -17,9 +17,13 @@
<div class="container" role="main">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
{{ with .Content }}
<div class="well">
{{.}}
</div>
{{ end }}
<div class="posts-list">
{{ $pag := .Paginate (where .Data.Pages "Type" "post") }}
{{ range $pag.Pages }}
{{ range .Paginator.Pages }}
<article class="post-preview">
<a href="{{ .Permalink }}">
<h2 class="post-title">{{ .Title }}</h2>
@ -54,6 +58,20 @@
</article>
{{ end }}
</div>
{{ if or (.Paginator.HasPrev) (.Paginator.HasNext) }}
<ul class="pager main-pager">
{{ if .Paginator.HasPrev }}
<li class="previous">
<a href="{{ .URL }}page/{{ .Paginator.Prev.PageNumber }}">&larr; Newer Posts</a>
</li>
{{ end }}
{{ if .Paginator.HasNext }}
<li class="next">
<a href="{{ .URL }}page/{{ .Paginator.Next.PageNumber }}">Older Posts &rarr;</a>
</li>
{{ end }}
</ul>
{{ end }}
</div>
</div>
</div>

View File

@ -1,6 +1,33 @@
{{ define "main" }}
<div class="container" role="main">
{{.Content}}
</div>
{{ end }}
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<article role="main" class="blog-post">
{{ .Content }}
</article>
<ul class="pager blog-pager">
{{ if .PrevInSection }}
<li class="previous">
<a href="{{ .PrevInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .PrevInSection.Title }}">&larr; {{ i18n "previousPost" }}</a>
</li>
{{ end }}
{{ if .NextInSection }}
<li class="next">
<a href="{{ .NextInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .NextInSection.Title }}">{{ i18n "nextPost" }} &rarr;</a>
</li>
{{ end }}
</ul>
{{ if (.Params.comments) | or (and (or (not (isset .Params "comments")) (eq .Params.comments nil)) (.Site.Params.comments)) }}
{{ if .Site.DisqusShortname }}
<div class="disqus-comments">
{{ template "_internal/disqus.html" . }}
</div>
{{ end }}
{{ end }}
</div>
</div>
</div>
{{ end }}

View File

@ -1,17 +0,0 @@
{{ define "main" }}
<div class="container" role="main">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
{{ .Content }}
{{ if (.Params.comments) | or (and (or (not (isset .Params "comments")) (eq .Params.comments nil)) (.Site.Params.comments)) }}
{{ if .Site.DisqusShortname }}
<div class="disqus-comments">
{{ template "_internal/disqus.html" . }}
</div>
{{ end }}
{{ end }}
</div>
</div>
</div>
{{ end }}

View File

@ -1,34 +0,0 @@
{{ define "main" }}
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<article role="main" class="blog-post">
{{ .Content }}
</article>
<ul class="pager blog-pager">
{{ if .PrevInSection }}
<li class="previous">
<a href="{{ .PrevInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .PrevInSection.Title }}">&larr; {{ i18n "previousPost" }}</a>
</li>
{{ end }}
{{ if .NextInSection }}
<li class="next">
<a href="{{ .NextInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .NextInSection.Title }}">{{ i18n "nextPost" }} &rarr;</a>
</li>
{{ end }}
</ul>
{{ if (.Params.comments) | or (and (or (not (isset .Params "comments")) (eq .Params.comments nil)) (.Site.Params.comments)) }}
{{ if .Site.DisqusShortname }}
<div class="disqus-comments">
{{ template "_internal/disqus.html" . }}
</div>
{{ end }}
{{ end }}
</div>
</div>
</div>
{{ end }}