Fix ordering of conditionals to allow both single page site mode and normal blog mode. Add semantic tags

This commit is contained in:
Justin Nguyen 2020-12-22 13:13:02 -08:00
parent 896dbba4cf
commit a667d2d6db
3 changed files with 60 additions and 31 deletions

View File

@ -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]

View File

@ -6,33 +6,35 @@
</div>
{{ end }}
{{ if .Site.Params.singlePageSite }}
<!-- Variables for collection of posts -->
{{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "posts") (eq (trim $.Site.Params.contentTypeName " ") "")) }}
{{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "posts" }}
<!-- Variables for collection of 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) }}
<div class="sections">
{{ range .Site.Menus.main }}
{{ if in (first 2 .URL) "#" }}
<div id="{{ .Identifier }}" class="posts section">
<h1 class="section-header">{{ .Name }}</h1>
<div class="sections">
{{ range .Site.Menus.main }}
{{ if eq (first 2 .URL) "/#" }}
<section id="{{ .Identifier }}" class="posts section">
{{ if $.Site.Params.singlePageSite }}
<h1 class="section-header">{{ .Name }}<a href="#{{ .Identifier }}" class="hanchor" arialabel="Anchor"></a></h1>
{{ end }}
{{ if ne .Identifier $.Site.Params.contentTypeName }}
<div class="post">
{{ $section := path.Join "homepage" .Identifier }}
{{ with $.Site.GetPage $section }}
{{ partial "section.html" . }}
{{ end }}
</div>
{{ if $.Site.Params.singlePageSite }}
<div class="post">
{{ $section := path.Join "homepage" .Identifier }}
{{ with $.Site.GetPage $section }}
{{ partial "section.html" . }}
{{ end }}
</div>
{{ end }}
{{ else }}
{{ range $paginator.Pages }}
<div class="post on-list">
<article class="post on-list">
<h1 class="post-title">
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
</h1>
@ -81,16 +83,29 @@
href="{{.RelPermalink}}">{{ $.Site.Params.ReadMore }} →</a>
</div>
{{ end }}
</div>
</article>
{{ end }}
{{ if $.Site.Params.singlePageSite }}
<div class="pagination">
<div class="pagination__buttons">
<span class="button previous">
<a href="{{ $.Site.Params.singlePageCollectionSeeMoreLink }}">
<span class="button__icon"></span>
<span class="button__text">{{ $.Site.Params.singlePageCollectionSeeMoreText }}</span>
</a>
</span>
</div>
</div>
{{ else }}
{{ partial "pagination.html" $ }} <!-- originally . instead of $ -->
{{ end }}
<!--{ { partial "pagination.html" $ } }--> TODO: Update pagination <!-- originally . instead of $ -->
{{ end }}
</div>
<hr class="section-separator">
</section>
{{ if $.Site.Params.singlePageSite }}
<hr class="section-separator">
{{ end }}
{{ end }}
</div>
{{ end }}
</div>
{{ end }}
{{ end }}

View File

@ -6,7 +6,7 @@
{{ end }}
<div class="posts">
{{ range .Pages }}
<div class="post on-list">
<article class="post on-list">
<h1 class="post-title">
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
</h1>
@ -55,7 +55,7 @@
href="{{.RelPermalink}}">{{ $.Site.Params.ReadMore }} →</a>
</div>
{{ end }}
</div>
</article>
{{ end }}
{{ partial "pagination.html" . }}
</div>