diff options
author | Jeremy Bise <jeremy.bise@thosegeeks.com> | 2019-04-26 20:06:01 +0300 |
---|---|---|
committer | Jeremy Bise <jeremy.bise@thosegeeks.com> | 2019-04-26 20:06:01 +0300 |
commit | 8c56f7e5d6ad66a811ff745b6a4db8f580f8be34 (patch) | |
tree | f16e895d334a312e7eb11cdbf3e8481185b91b75 | |
parent | e5c4f45afe0a5c93e36d039ee6c727c642c26694 (diff) |
homepage and footer recent posts use mainSections
-rw-r--r-- | exampleSite/config.toml | 4 | ||||
-rw-r--r-- | layouts/index.html | 64 | ||||
-rw-r--r-- | layouts/partials/footer/footer-widgets.html | 2 |
3 files changed, 64 insertions, 6 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index e4aa571..55d1984 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -3,10 +3,6 @@ languageCode = "en-us" title = "My New Hugo Site" theme = "twentynineteen-hugo" -# Syntax highlighting -pygmentsUseClasses=true -pygmentsCodefences=true - # Pagination paginate = 5 diff --git a/layouts/index.html b/layouts/index.html index c6074fb..2026341 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,3 +1,65 @@ {{ define "main" }} - {{ partial "posts/post-list" . }} +{{ $paginator := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections) }} + +{{ range $paginator.Pages }} + <article class="post entry"> + <header class="entry-header"> + <h2 class="entry-title"> + <a href="{{ .RelPermalink }}" rel="bookmark">{{.Title}}</a> + </h2> + </header> + + {{ if .Params.image }} + <figure class="post-thumbnail"> + <a class="post-thumbnail-inner" href="{{ .RelPermalink }}" aria-hidden="true"> + <img src="{{ .Params.image }}" /> + </a> + </figure> + {{ end }} + + <div class="entry-content"> + {{ .Summary | markdownify }} + {{ if .Truncated }} + <div> + <a href="{{ .RelPermalink }}" class="more-link"> + Continue reading + </a> + </div> + {{ end }} + </div> + + <footer class="entry-footer"> + {{ partial "entry-meta" . }} + </footer> + </article> +{{ end }} + +{{ if gt $paginator.TotalPages 1 }} +<nav class="navigation pagination" role="navigation"> + <h2 class="screen-reader-text">Posts navigation</h2> + <div class="nav-links"> + {{ if $paginator.HasPrev }} + <a class="prev page-numbers" href="{{ $paginator.Prev.URL }}"> + {{ partial "icons/ui/chevron-left" }} + <span class="nav-prev-text">Newer posts</span> + </a> + {{ end }} + + {{ range $paginator.Pagers }} + {{ if eq . $paginator }} + <span aria-current="page" class="page-numbers current">{{ .PageNumber }}</span> + {{ else }} + <a href="{{ .URL }}" class="page-numbers">{{ .PageNumber }}</a> + {{ end }} + {{ end }} + + {{ if $paginator.HasNext }} + <a class="next page-numbers" href="{{ $paginator.Next.URL }}"> + <span class="nav-next-text">Older posts</span> + {{ partial "icons/ui/chevron-right" }} + </a> + {{ end }} + </div> +</nav> +{{ end }} {{ end }}
\ No newline at end of file diff --git a/layouts/partials/footer/footer-widgets.html b/layouts/partials/footer/footer-widgets.html index b747c35..41f560e 100644 --- a/layouts/partials/footer/footer-widgets.html +++ b/layouts/partials/footer/footer-widgets.html @@ -13,7 +13,7 @@ <section id="recent-posts" class="widget widget_recent_entries"> <h2 class="widget-title">Recent Posts</h2> <ul> - {{ range first 5 (where .Site.Pages.ByPublishDate.Reverse "Section" "post") }} + {{ range first 5 (where site.RegularPages.ByPublishDate.Reverse "Type" "in" site.Params.mainSections) }} <li> <a href="{{ .RelPermalink }}">{{ .Title }}</a> </li> |