Move recent posts list to a shortcode and include it in the index content file

This commit is contained in:
Eryn Wells 2021-10-10 10:55:21 -07:00
parent 2840913b7d
commit ce41555c3d
3 changed files with 28 additions and 28 deletions

View file

@ -10,6 +10,10 @@ where I got a degree in Computer Science. {{< tess >}} is my girlfriend.
I speak English natively, and Spanish too, though I always need more practice.
## Recent Posts
{{< recent_posts >}}
## Hobbies
I have a big appetite for learning new skills, especially things that combine

View file

@ -9,32 +9,4 @@
{{ .Content }}
</section>
<!-- $pages -->
{{ $pages := union .RegularPages .Sections }}
<!---->{{ if .IsHome }} {{ $pages = where site.RegularPages "Type" "in" site.Params.mainSections }}
{{ end }}
<!-- Articles -->
<section id="homepage-articles">
<h2>Recent Posts</h2>
<ul>
{{ $paginator := .Paginate $pages }}
{{ range $index, $page := $paginator.Pages }}
<li><a href="{{ .Permalink }}">{{ .Title }}</a><time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date | time.Format ":date_medium" }}</time></li>
{{ end }}
</ul>
</section>
<!-- Main Nav -->
{{ if gt $paginator.TotalPages 1 }}
<nav class="main-nav">
{{ if $paginator.HasPrev }}
<a class="prev" href="{{ $paginator.Prev.URL }}">← {{ i18n "prev_page" }}</a>
{{ end }}<!---->
{{ if $paginator.HasNext }}
<a class="next" href="{{ $paginator.Next.URL }}">{{ i18n "next_page" }} →</a>
{{ end }}
</nav>
{{ end }}<!---->
{{ end }}

View file

@ -0,0 +1,24 @@
<ul>
{{ $pages := union .Site.RegularPages .Site.Sections }}
{{ if .Page.IsHome }}
{{ $pages = where site.RegularPages "Type" "in" site.Params.mainSections }}
{{ end }}
{{ $paginator := .Page.Paginate $pages }}
{{ range $index, $page := $paginator.Pages }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date | time.Format ":date_medium" }}</time>
</li>
{{ end }}
</ul>
{{ if gt $paginator.TotalPages 1 }}
<nav class="main-nav">
{{ if $paginator.HasPrev }}
<a class="prev" href="{{ $paginator.Prev.URL }}">← {{ i18n "prev_page" }}</a>
{{ end }}<!---->
{{ if $paginator.HasNext }}
<a class="next" href="{{ $paginator.Next.URL }}">{{ i18n "next_page" }} →</a>
{{ end }}
</nav>
{{ end }}<!---->