From a667d2d6db47666e643aad71d88e2726f61a4544 Mon Sep 17 00:00:00 2001 From: Justin Nguyen Date: Tue, 22 Dec 2020 13:13:02 -0800 Subject: [PATCH] Fix ordering of conditionals to allow both single page site mode and normal blog mode. Add semantic tags --- exampleSite/config.toml | 14 +++++++ layouts/_default/index.html | 73 ++++++++++++++++++++++--------------- layouts/_default/list.html | 4 +- 3 files changed, 60 insertions(+), 31 deletions(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index bec37f5..0a19073 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -9,6 +9,20 @@ paginate = 5 showMenuItems = 2 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. + 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" + +[params.twitter] + creator = "@justinnuwin" + site = "@justinnuwin" + [languages] [languages.en] diff --git a/layouts/_default/index.html b/layouts/_default/index.html index d0a9836..924d824 100644 --- a/layouts/_default/index.html +++ b/layouts/_default/index.html @@ -6,33 +6,35 @@ {{ end }} -{{ if .Site.Params.singlePageSite }} + +{{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "posts") (eq (trim $.Site.Params.contentTypeName " ") "")) }} +{{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "posts" }} - - {{ $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 }} +{{ end }} +{{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }} - {{ $PageContext := . }} - {{ if .IsHome }} - {{ $PageContext = .Site }} - {{ end }} - {{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }} - -
- {{ range .Site.Menus.main }} - {{ if in (first 2 .URL) "#" }} -
-

{{ .Name }}

+
+ {{ range .Site.Menus.main }} + {{ if eq (first 2 .URL) "/#" }} +
+ {{ if $.Site.Params.singlePageSite }} +

{{ .Name }}

+ {{ end }} {{ if ne .Identifier $.Site.Params.contentTypeName }} -
- {{ $section := path.Join "homepage" .Identifier }} - {{ with $.Site.GetPage $section }} - {{ partial "section.html" . }} - {{ end }} -
+ {{ if $.Site.Params.singlePageSite }} +
+ {{ $section := path.Join "homepage" .Identifier }} + {{ with $.Site.GetPage $section }} + {{ partial "section.html" . }} + {{ end }} +
+ {{ end }} {{ else }} {{ range $paginator.Pages }} -
+
{{ end }} -
+ + {{ end }} + {{ if $.Site.Params.singlePageSite }} + + {{ else }} + {{ partial "pagination.html" $ }} {{ end }} - TODO: Update pagination {{ end }} -
-
+ + {{ if $.Site.Params.singlePageSite }} +
{{ end }} {{ end }} -
+ {{ end }} + {{ end }} - -{{ end }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index c7ce2e4..b7018d6 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -6,7 +6,7 @@ {{ end }}
{{ range .Pages }} -
+
{{ end }} -
+ {{ end }} {{ partial "pagination.html" . }}