mirror of
https://git.adityakumar.xyz/hugo-theme-introduction.git
synced 2024-11-09 14:59:45 +00:00
add archive format to all posts
This commit is contained in:
parent
6925c0248c
commit
630c4c6b48
4 changed files with 55 additions and 27 deletions
|
@ -20,6 +20,7 @@ DefaultContentLanguage = "en" # Default language fo
|
||||||
introHeight = "fullheight" # Input either "medium" or "large" or "fullheight"
|
introHeight = "fullheight" # Input either "medium" or "large" or "fullheight"
|
||||||
showLatest = true # Show latest blog post summary
|
showLatest = true # Show latest blog post summary
|
||||||
showAllPosts = false # Set true to list all posts on home page, or set false to link to separate blog list page
|
showAllPosts = false # Set true to list all posts on home page, or set false to link to separate blog list page
|
||||||
|
allPostsArchiveFormat = true # show all posts in an archive format
|
||||||
numberOfProjectsToShow = 3 # Maximum number of projects to show on home page. Unset or comment out to show all projects
|
numberOfProjectsToShow = 3 # Maximum number of projects to show on home page. Unset or comment out to show all projects
|
||||||
localTime = true # Show your current local time in contact section
|
localTime = true # Show your current local time in contact section
|
||||||
timeZone = "America/Los_Angeles" # Your timezone as in the TZ* column of this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
timeZone = "America/Los_Angeles" # Your timezone as in the TZ* column of this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||||
|
|
|
@ -5,24 +5,27 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
{{ if .Site.Params.home.showLatest | default true }}
|
{{ if .Site.Params.home.showLatest | default true }}
|
||||||
<h2 class="title is-2 top-pad">{{ i18n "index_blog_latestPosts" . }}</h2>
|
<h2 class="title is-2 top-pad">{{ i18n "index_blog_latestPosts" . }}</h2>
|
||||||
{{ range first 1 .Pages.ByPublishDate.Reverse }}
|
{{ range first 1 .Pages.ByPublishDate.Reverse }}
|
||||||
<div class="summary">{{ if .Params.date }}{{ .Date.Format (.Site.Params.dateFormat | default "Jan 02, 2006") }}{{ end }}
|
<div class="summary">{{ if .Params.date }}{{ .Date.Format (.Site.Params.dateFormat | default "Jan 02, 2006") }}{{ end }}
|
||||||
<h3 class="title is-3 strong-post-title">
|
<h3 class="title is-3 strong-post-title">
|
||||||
<a href="{{ .Permalink }}">
|
<a href="{{ .Permalink }}">
|
||||||
{{ .Title | markdownify }}
|
{{ .Title | markdownify }}
|
||||||
</a>
|
</a>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="markdown">
|
<div class="markdown">
|
||||||
{{ .Summary }}
|
{{ .Summary }}
|
||||||
{{ if .Truncated }}
|
{{ if .Truncated }}
|
||||||
<a href="{{ .Permalink }}">{{ i18n "index_blog_readMore" . }}</a>
|
<a href="{{ .Permalink }}">{{ i18n "index_blog_readMore" . }}</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{{ end }}
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<h2 class="title is-2 top-pad">{{ i18n "index_blog_allPosts" . }}</h2>
|
<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>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
18
layouts/partials/blog/archive.html
Normal file
18
layouts/partials/blog/archive.html
Normal file
|
@ -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>
|
|
@ -16,22 +16,28 @@
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if .Site.Params.home.showAllPosts }}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="all-posts">
|
{{ if .Site.Params.home.showAllPosts }}
|
||||||
<div class="container">
|
<div class="section" id="all-posts">
|
||||||
<h2 class="title is-2 has-text-centered top-pad">{{ i18n "index_blog_allPosts" . }}</h2>
|
<div class="container">
|
||||||
{{ partialCached "blog/li.html" . }}
|
<h2 class="title is-2 top-pad">{{ i18n "index_blog_allPosts" . }}</h2>
|
||||||
{{ else }}
|
{{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">
|
<div class="container has-text-centered top-pad">
|
||||||
<a href="{{ .Permalink }}">{{ i18n "index_blog_allPosts" . }}</a>
|
<a href="{{ .Permalink }}">{{ i18n "index_blog_allPosts" . }}</a>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
|
||||||
<!-- End Blog container -->
|
<!-- End Blog container -->
|
||||||
{{ partial "top-icon.html" . }}
|
{{ partial "top-icon.html" . }}
|
||||||
</div>
|
|
||||||
<!-- End Blog section -->
|
<!-- End Blog section -->
|
||||||
<div class="container"><hr></div>
|
<div class="container"><hr></div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in a new issue