diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 0a19073..6c5ac13 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -1,7 +1,7 @@ baseurl = "https://example.com/" languageCode = "en-us" theme = "hugo-theme-terminal" -paginate = 5 +paginate = 10 [params] contentTypeName = "post" @@ -10,14 +10,10 @@ paginate = 5 fullWidthTheme = false centerTheme = false # singlePageSite moves pages from the main nav menu to sections on the homepage. - # These only menu items with a url set to "/#section-name" will be displayed. - # A collection is displayed for the menu identifier which matches contentTypeName. - # The collection items use the "post" archetypes. + # These only menu items with a url starting with "/#" will be displayed using the + # front matter defined in "homepage/". A collection is displayed for other menu items. singlePageSite = true - # For singlePageSites the collection is paginated but it would not make sense to - # paginate in the middle of a section, so a link to see more can be specified below. - singlePageCollectionSeeMoreText = "Check out my projects!" - singlePageCollectionSeeMoreLink = "/portfolio" + homepagePaginateCount = 10 # If you want the homepage to paginate a different numebr of items [params.twitter] creator = "@justinnuwin" diff --git a/layouts/_default/index.html b/layouts/_default/index.html index bd08494..fc3a8ec 100644 --- a/layouts/_default/index.html +++ b/layouts/_default/index.html @@ -1,5 +1,6 @@ {{ define "main" }} + {{ if .Content }}
{{ .Content }} @@ -14,98 +15,50 @@ {{ if .IsHome }} {{ $PageContext = .Site }} {{ end }} -{{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }} -
- {{ range .Site.Menus.main }} - {{ if eq (first 2 .URL) "/#" }} + +{{ if $.Site.Params.singlePageSite }} +
+ {{ range .Site.Menus.main }}
- {{ if $.Site.Params.singlePageSite }} + {{ if eq (first 2 .URL) "/#" }}

{{ .Name }}

- {{ end }} - {{ if ne .Identifier $.Site.Params.contentTypeName }} - {{ if $.Site.Params.singlePageSite }} -
- {{ $section := path.Join "homepage" .Identifier }} - {{ with $.Site.GetPage $section }} - {{ partial "section.html" . }} - {{ end }} -
- {{ end }} +
+ {{ $section := path.Join "homepage" .Identifier }} + {{ with $.Site.GetPage $section }} + {{ partial "section.html" . }} + {{ end }} +
{{ else }} - {{ range $paginator.Pages.ByDate.Reverse }} -
-

- {{ .Title | markdownify }} -

- - - {{ if .Params.tags }} - - {{ end }} - - {{ if .Params.Cover }} - {{ .Title | plainify | default - {{ end }} - -
- {{ if .Params.showFullContent }} - {{ .Content | markdownify }} - {{ else if .Description }} - {{ .Description | markdownify }} - {{ else }} - {{ if .Truncated }} - {{ .Summary | markdownify }} - {{ end }} - {{ end }} -
- - {{ if not .Params.showFullContent }} - - {{ end }} -
+

{{ .Name }}

+ {{ $thisSectionsPages := where $PageContext.RegularPages "Type" .Identifier }} + {{ range first $.Site.Params.homepagePaginateCount $thisSectionsPages.ByDate.Reverse }} + {{ partial "collection.html" . }} {{ end }} - {{ if $.Site.Params.singlePageSite }} -
- {{ if $.Site.Params.singlePageSite }} -
- {{ end }} +
{{ end }} - {{ end }} -
- +
+{{ else }} +
+ {{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }} + {{ range $paginator.Pages.ByDate.Reverse }} + {{ partial "collection.html" . }} + {{ end }} + {{ partial "pagination.html" . }} +
+{{ end }} + + {{ end }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index baea65b..61dca88 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -6,56 +6,7 @@ {{ end }}
{{ range .Pages.ByDate.Reverse }} -
-

- {{ .Title | markdownify }} -

- - - {{ if .Params.tags }} - - {{ end }} - - {{ if .Params.Cover }} - {{ .Title | plainify | default - {{ end }} - -
- {{ if .Params.showFullContent }} - {{ .Content | markdownify }} - {{ else if .Description }} - {{ .Description | markdownify }} - {{ else }} - {{ if .Truncated }} - {{ .Summary | markdownify }} - {{ end }} - {{ end }} -
- - {{ if not .Params.showFullContent }} -
- {{ $.Site.Params.ReadMore }} → -
- {{ end }} -
+ {{ partial "collection.html" . }} {{ end }} {{ partial "pagination.html" . }}
diff --git a/layouts/partials/collection.html b/layouts/partials/collection.html new file mode 100644 index 0000000..3c1da6d --- /dev/null +++ b/layouts/partials/collection.html @@ -0,0 +1,50 @@ +
+

+ {{ .Title | markdownify }} +

+ + + {{ if .Params.tags }} + + {{ end }} + + {{ if .Params.Cover }} + {{ .Title | plainify | default + {{ end }} + +
+ {{ if .Params.showFullContent }} + {{ .Content | markdownify }} + {{ else if .Description }} + {{ .Description | markdownify }} + {{ else }} + {{ if .Truncated }} + {{ .Summary | markdownify }} + {{ end }} + {{ end }} +
+ + {{ if not .Params.showFullContent }} +
+ {{ $.Site.Params.ReadMore }} → +
+ {{ end }} +