Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/vickylaixy/hugo-theme-introduction.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelo <AIRyndon@users.noreply.github.com>2020-12-24 11:31:47 +0300
committerAngelo <AIRyndon@users.noreply.github.com>2020-12-24 11:31:47 +0300
commit630c4c6b48344901eef91d6153cba5cae5a2a15a (patch)
tree26cf835dc21011a9bd31ca29a22c5ecfff30e55d /layouts
parent6925c0248cf70674576d42d173ff33b00a3d522a (diff)
add archive format to all posts
Diffstat (limited to 'layouts')
-rw-r--r--layouts/blog/list.html35
-rw-r--r--layouts/partials/blog/archive.html18
-rw-r--r--layouts/partials/home/blog.html28
3 files changed, 54 insertions, 27 deletions
diff --git a/layouts/blog/list.html b/layouts/blog/list.html
index 95085c5..d3aea07 100644
--- a/layouts/blog/list.html
+++ b/layouts/blog/list.html
@@ -5,24 +5,27 @@
<div class="container">
{{ if .Site.Params.home.showLatest | default true }}
<h2 class="title is-2 top-pad">{{ i18n "index_blog_latestPosts" . }}</h2>
- {{ range first 1 .Pages.ByPublishDate.Reverse }}
- <div class="summary">{{ if .Params.date }}{{ .Date.Format (.Site.Params.dateFormat | default "Jan 02, 2006") }}{{ end }}
- <h3 class="title is-3 strong-post-title">
- <a href="{{ .Permalink }}">
- {{ .Title | markdownify }}
- </a>
- </h3>
- <div class="markdown">
- {{ .Summary }}
- {{ if .Truncated }}
- <a href="{{ .Permalink }}">{{ i18n "index_blog_readMore" . }}</a>
- {{ end }}
+ {{ range first 1 .Pages.ByPublishDate.Reverse }}
+ <div class="summary">{{ if .Params.date }}{{ .Date.Format (.Site.Params.dateFormat | default "Jan 02, 2006") }}{{ end }}
+ <h3 class="title is-3 strong-post-title">
+ <a href="{{ .Permalink }}">
+ {{ .Title | markdownify }}
+ </a>
+ </h3>
+ <div class="markdown">
+ {{ .Summary }}
+ {{ if .Truncated }}
+ <a href="{{ .Permalink }}">{{ i18n "index_blog_readMore" . }}</a>
+ {{ end }}
+ </div>
</div>
- </div>
- {{ end }}
-
+ {{ end }}
{{ end }}
<h2 class="title is-2 top-pad">{{ i18n "index_blog_allPosts" . }}</h2>
- {{ partialCached "blog/li.html" . }}
+ {{if .Site.Params.home.allPostsArchiveFormat}}
+ {{ partialCached "blog/archive.html" .}}
+ {{else}}
+ {{ partialCached "blog/li.html" . }}
+ {{end}}
</div>
{{ end }}
diff --git a/layouts/partials/blog/archive.html b/layouts/partials/blog/archive.html
new file mode 100644
index 0000000..eaba407
--- /dev/null
+++ b/layouts/partials/blog/archive.html
@@ -0,0 +1,18 @@
+<section>
+ {{ $prev := 2100}} <!--start at year 2100-->
+ {{range .Pages.ByPublishDate.Reverse}}
+ {{if .Date}}
+ {{$curr := .Date.Format "2006"}}
+ {{if gt $prev ($curr)}}
+ <h2 class="title is-2 top-pad">{{ $curr }}</h2>
+ {{end}}
+ <li class="post-item">
+ {{ if .Params.date }}
+ <span>{{ .Date.Format (.Site.Params.dateFormat | default "Jan 02, 2006") }}</span> -
+ {{ end }}
+ <span><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></span>
+ </li>
+ {{ $prev = $curr}}
+ {{end}}
+ {{end}}
+</section>
diff --git a/layouts/partials/home/blog.html b/layouts/partials/home/blog.html
index 0582a20..9f6cd59 100644
--- a/layouts/partials/home/blog.html
+++ b/layouts/partials/home/blog.html
@@ -16,22 +16,28 @@
</div>
{{ end }}
{{ end }}
- {{ if .Site.Params.home.showAllPosts }}
</div>
</div>
-<div class="section" id="all-posts">
- <div class="container">
- <h2 class="title is-2 has-text-centered top-pad">{{ i18n "index_blog_allPosts" . }}</h2>
- {{ partialCached "blog/li.html" . }}
- {{ else }}
+ {{ if .Site.Params.home.showAllPosts }}
+ <div class="section" id="all-posts">
+ <div class="container">
+ <h2 class="title is-2 top-pad">{{ i18n "index_blog_allPosts" . }}</h2>
+ {{if .Site.Params.home.allPostsArchiveFormat}}
+ {{ partialCached "blog/archive.html" .}}
+ {{else}}
+ {{ partialCached "blog/li.html" . }}
+ {{end}}
+ </div>
+ </div>
+ {{ else }}
<div class="container has-text-centered top-pad">
<a href="{{ .Permalink }}">{{ i18n "index_blog_allPosts" . }}</a>
</div>
- {{ end }}
- </div>
- <!-- End Blog container -->
- {{ partial "top-icon.html" . }}
-</div>
+ {{ end }}
+
+<!-- End Blog container -->
+{{ partial "top-icon.html" . }}
+
<!-- End Blog section -->
<div class="container"><hr></div>
{{ end }}