Skip to content

Commit 9a65a1b

Browse files
committed
Display Content By Creation Date Descending
1 parent 6044281 commit 9a65a1b

File tree

3 files changed

+182
-0
lines changed

3 files changed

+182
-0
lines changed

layouts/_default/index.html

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{{ define "main" }}
2+
{{ if .Content }}
3+
<div class="index-content {{ if .Params.framed -}}framed{{- end -}}">
4+
{{ .Content }}
5+
</div>
6+
{{ end }}
7+
<div class="posts">
8+
{{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "posts") (eq (trim $.Site.Params.contentTypeName " ") "")) }}
9+
{{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "posts" }}
10+
11+
{{ $PageContext := . }}
12+
{{ if .IsHome }}
13+
{{ $PageContext = .Site }}
14+
{{ end }}
15+
{{ $allPages := (where $PageContext.RegularPages "Type" $contentTypeName).ByDate.Reverse }}
16+
{{ $paginator := .Paginate $allPages }}
17+
18+
{{ range $paginator.Pages }}
19+
<article class="post on-list">
20+
<h2 class="post-title">
21+
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
22+
</h2>
23+
24+
<div class="post-meta">
25+
{{- if .Date -}}
26+
<time class="post-date">
27+
{{- partial "post-date" . -}}
28+
</time>
29+
{{- end -}}
30+
{{- with .Params.Author -}}
31+
<span class="post-author">{{ . }}</span>
32+
{{- end -}}
33+
</div>
34+
35+
{{ if .Params.tags }}
36+
<span class="post-tags">
37+
{{ range .Params.tags }}
38+
#<a href="{{ (urlize (printf "tags/%s/" . )) | absLangURL }}">
39+
{{- . -}}
40+
</a>&nbsp;
41+
{{ end }}
42+
</span>
43+
{{ end }}
44+
45+
{{ partial "cover.html" . }}
46+
47+
<div class="post-content">
48+
{{ if .Params.showFullContent }}
49+
{{ .Content }}
50+
{{ else if .Description }}
51+
<p>{{ .Description | markdownify }}</p>
52+
{{ else }}
53+
{{ .Summary }}
54+
{{ end }}
55+
</div>
56+
57+
{{ if not .Params.showFullContent }}
58+
<div>
59+
<a class="read-more button inline" href="{{ .RelPermalink }}">[{{ $.Site.Params.ReadMore }}]</a>
60+
</div>
61+
{{ end }}
62+
</article>
63+
{{ end }}
64+
65+
{{ partial "pagination.html" . }}
66+
</div>
67+
{{ end }}

layouts/_default/list.html

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{{ define "main" }}
2+
{{ with .Content }}
3+
<div class="index-content">
4+
{{ . }}
5+
</div>
6+
{{ end }}
7+
<div class="posts">
8+
{{ $paginator := .Paginate (.Pages.ByDate.Reverse) }}
9+
{{ range $paginator.Pages }}
10+
<article class="post on-list">
11+
<h2 class="post-title">
12+
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
13+
</h2>
14+
<div class="post-meta">
15+
{{- if .Date -}}
16+
<time class="post-date">
17+
{{- partial "post-date" . -}}
18+
</time>
19+
{{- end -}}
20+
{{- with .Params.Author -}}
21+
<span class="post-author">{{- . -}}</span>
22+
{{- end -}}
23+
</div>
24+
25+
{{ if .Params.tags }}
26+
<span class="post-tags">
27+
{{ range .Params.tags }}
28+
#<a href="{{ (urlize (printf "tags/%s/" . )) | absLangURL }}">
29+
{{- . -}}
30+
</a>&nbsp;
31+
{{ end }}
32+
</span>
33+
{{ end }}
34+
35+
{{ partial "cover.html" . }}
36+
37+
<div class="post-content">
38+
{{ if .Params.showFullContent }}
39+
{{ .Content }}
40+
{{ else if .Description }}
41+
<p>{{ .Description | markdownify }}</p>
42+
{{ else }}
43+
{{ .Summary }}
44+
{{ end }}
45+
</div>
46+
47+
{{ if not .Params.showFullContent }}
48+
<div>
49+
<a class="read-more button inline" href="{{ .RelPermalink }}">[{{ $.Site.Params.ReadMore }}]</a>
50+
</div>
51+
{{ end }}
52+
</article>
53+
{{ end }}
54+
55+
{{ partial "pagination.html" . }}
56+
</div>
57+
{{ end }}

layouts/_default/term.html

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{{ define "main" }}
2+
<h1>Posts for: #{{ .Title }}</h1>
3+
{{ with .Content }}
4+
<div class="index-content">
5+
{{ . }}
6+
</div>
7+
{{ end }}
8+
<div class="posts">
9+
{{ $paginator := .Paginate (.Pages.ByDate.Reverse) }}
10+
{{ range $paginator.Pages }}
11+
<article class="post on-list">
12+
<h1 class="post-title">
13+
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
14+
</h1>
15+
<div class="post-meta">
16+
{{- if .Date -}}
17+
<time class="post-date">
18+
{{- .Date.Format "2006-01-02" -}}
19+
</time>
20+
{{- end -}}
21+
{{- with .Params.Author -}}
22+
<span class="post-author">{{- . -}}</span>
23+
{{- end -}}
24+
</div>
25+
26+
{{ if .Params.tags }}
27+
<span class="post-tags">
28+
{{ range .Params.tags }}
29+
#<a href="{{ (urlize (printf "tags/%s/" . )) | absLangURL }}">
30+
{{- . -}}
31+
</a>&nbsp;
32+
{{ end }}
33+
</span>
34+
{{ end }}
35+
36+
{{ partial "cover.html" . }}
37+
38+
<div class="post-content">
39+
{{ if .Params.showFullContent }}
40+
{{ .Content }}
41+
{{ else if .Description }}
42+
<p>{{ .Description | markdownify }}</p>
43+
{{ else }}
44+
{{ .Summary }}
45+
{{ end }}
46+
</div>
47+
48+
{{ if not .Params.showFullContent }}
49+
<div>
50+
<a class="read-more button inline" href="{{ .RelPermalink }}">[{{ $.Site.Params.ReadMore }}]</a>
51+
</div>
52+
{{ end }}
53+
</article>
54+
{{ end }}
55+
56+
{{ partial "pagination.html" . }}
57+
</div>
58+
{{ end }}

0 commit comments

Comments
 (0)