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="container" role="main">
<div class="row"> <div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> <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"> <div class="posts-list">
{{ $pag := .Paginate (where .Data.Pages "Type" "post") }} {{ range .Paginator.Pages }}
{{ range $pag.Pages }}
<article class="post-preview"> <article class="post-preview">
<a href="{{ .Permalink }}"> <a href="{{ .Permalink }}">
<h2 class="post-title">{{ .Title }}</h2> <h2 class="post-title">{{ .Title }}</h2>
@ -54,6 +58,20 @@
</article> </article>
{{ end }} {{ end }}
</div> </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> </div>
</div> </div>

View File

@ -1,6 +1,33 @@
{{ define "main" }} {{ define "main" }}
<div class="container" role="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 }} {{ .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> </div>
{{ end }} {{ 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 }}