Skip to content

Commit

Permalink
Adapt theme to be compatible with hugoBasicExample
Browse files Browse the repository at this point in the history
_default/{archives,list}.html utilize .site.Params.mainSections

This flexible option let's users decide what content pages they want to
display in the archive and on the homepage. By default, Hugo adds
content types with the most content files as a good heuristic. Can be
overwritten at any time in the config file.

Signed-off-by: Aditya Telange <21258296+adityatelange@users.noreply.github.com>
  • Loading branch information
digitalcraftsman authored and adityatelange committed Sep 12, 2020
1 parent 75d5acc commit ab14f2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions layouts/_default/archives.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<div class="archive">
<header class="page-header"><h1>{{ .Title }}</h1></header>

{{ range .Site.RegularPages.GroupByPublishDate "2006" }}
{{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }}
{{ range $pages.GroupByPublishDate "2006" }}
{{ if ne .Key "0001" }}
<div class="archive-year">
<h2 class="archive-year-header">{{ replace .Key "0001" "" }}</h2>
Expand Down
20 changes: 10 additions & 10 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
{{- partial "indexProfile.html" . }}
{{else}} {{/* if not profileMode */}}

{{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "posts") (eq (trim $.Site.Params.contentTypeName " ") "")) }}
{{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "posts" }}

{{ $PageContext := . }}
{{ if .IsHome }}
{{ $PageContext = .Site }}
{{else}}
{{- if .Title }}
{{- if not .IsHome | and .Title }}
<header class="page-header">
<h1>{{ .Title }}</h1>
</header>
{{ end }}
{{ end }}
{{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }}


{{ $pages := .RegularPages }}

{{ if .IsHome }}
{{ $pages = where site.RegularPages "Type" "in" site.Params.mainSections }}
{{end}}

{{ $paginator := .Paginate $pages }}

{{- range $index, $page := $paginator.Pages }}

Expand Down

1 comment on commit ab14f2f

@adityatelange
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.