Clean up templates a whole bunch by making single page layout, a true single page layout
This commit is contained in:
parent
50b7892a15
commit
5992889676
@ -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"
|
||||
|
@ -1,5 +1,6 @@
|
||||
{{ define "main" }}
|
||||
|
||||
|
||||
{{ if .Content }}
|
||||
<div class="index-content {{ if .Params.framed -}}framed{{- end -}}">
|
||||
{{ .Content }}
|
||||
@ -14,98 +15,50 @@
|
||||
{{ if .IsHome }}
|
||||
{{ $PageContext = .Site }}
|
||||
{{ end }}
|
||||
{{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }}
|
||||
|
||||
<div class="sections">
|
||||
{{ range .Site.Menus.main }}
|
||||
{{ if eq (first 2 .URL) "/#" }}
|
||||
|
||||
{{ if $.Site.Params.singlePageSite }}
|
||||
<div class="sections">
|
||||
{{ range .Site.Menus.main }}
|
||||
<section id="{{ .Identifier }}" class="posts section">
|
||||
{{ if $.Site.Params.singlePageSite }}
|
||||
{{ if eq (first 2 .URL) "/#" }}
|
||||
<h1 class="section-header">{{ .Name }}<a href="#{{ .Identifier }}" class="hanchor" arialabel="Anchor">⌗</a></h1>
|
||||
{{ end }}
|
||||
{{ if ne .Identifier $.Site.Params.contentTypeName }}
|
||||
{{ if $.Site.Params.singlePageSite }}
|
||||
<div class="post">
|
||||
{{ $section := path.Join "homepage" .Identifier }}
|
||||
{{ with $.Site.GetPage $section }}
|
||||
{{ partial "section.html" . }}
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
<div class="post">
|
||||
{{ $section := path.Join "homepage" .Identifier }}
|
||||
{{ with $.Site.GetPage $section }}
|
||||
{{ partial "section.html" . }}
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ else }}
|
||||
{{ range $paginator.Pages.ByDate.Reverse }}
|
||||
<article class="post on-list">
|
||||
<h1 class="post-title">
|
||||
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
|
||||
</h1>
|
||||
<div class="post-meta">
|
||||
<span class="post-date">
|
||||
{{ with .Params.daterange }}
|
||||
{{ . }}
|
||||
{{ else }}
|
||||
{{ .Date.Format "01-02-2006" }}
|
||||
{{ end }}
|
||||
</span>
|
||||
{{ with .Params.Author }}
|
||||
<span class="post-author">:: {{ . }}</span>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
{{ if .Params.tags }}
|
||||
<span class="post-tags">
|
||||
{{ range .Params.tags }}
|
||||
#<a href="{{ (urlize (printf "tags/%s/" . )) | absLangURL }}">
|
||||
{{- . -}}
|
||||
</a>
|
||||
{{ end }}
|
||||
</span>
|
||||
{{ end }}
|
||||
|
||||
{{ if .Params.Cover }}
|
||||
<img src="{{ .Params.Cover | absURL }}" class="post-cover" alt="{{ .Title | plainify | default " " }}" />
|
||||
{{ end }}
|
||||
|
||||
<div class="post-content">
|
||||
{{ if .Params.showFullContent }}
|
||||
{{ .Content | markdownify }}
|
||||
{{ else if .Description }}
|
||||
{{ .Description | markdownify }}
|
||||
{{ else }}
|
||||
{{ if .Truncated }}
|
||||
{{ .Summary | markdownify }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
{{ if not .Params.showFullContent }}
|
||||
<div>
|
||||
<a class="read-more button"
|
||||
href="{{.RelPermalink}}">{{ $.Site.Params.ReadMore }} →</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</article>
|
||||
<h1 class="section-header">{{ .Name }}<a href="{{ .URL }}" class="hanchor" arialabel="Anchor">⌗</a></h1>
|
||||
{{ $thisSectionsPages := where $PageContext.RegularPages "Type" .Identifier }}
|
||||
{{ range first $.Site.Params.homepagePaginateCount $thisSectionsPages.ByDate.Reverse }}
|
||||
{{ partial "collection.html" . }}
|
||||
{{ 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 class="pagination">
|
||||
<div class="pagination__buttons">
|
||||
<span class="button previous">
|
||||
<a href="{{ .URL }}">
|
||||
<span class="button__icon">→</span>
|
||||
<span class="button__text">See more {{ .Name | pluralize }}</span>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
{{ else }}
|
||||
{{ partial "pagination.html" $ }} <!-- originally . instead of $ -->
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</section>
|
||||
{{ if $.Site.Params.singlePageSite }}
|
||||
<hr class="section-separator">
|
||||
{{ end }}
|
||||
<hr class="section-separator">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
{{ else }}
|
||||
<div class="posts">
|
||||
{{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }}
|
||||
{{ range $paginator.Pages.ByDate.Reverse }}
|
||||
{{ partial "collection.html" . }}
|
||||
{{ end }}
|
||||
{{ partial "pagination.html" . }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
|
||||
{{ end }}
|
||||
|
@ -6,56 +6,7 @@
|
||||
{{ end }}
|
||||
<div class="posts">
|
||||
{{ range .Pages.ByDate.Reverse }}
|
||||
<article class="post on-list">
|
||||
<h1 class="post-title">
|
||||
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
|
||||
</h1>
|
||||
<div class="post-meta">
|
||||
<span class="post-date">
|
||||
{{ with .Params.daterange }}
|
||||
{{ . }}
|
||||
{{ else }}
|
||||
{{ .Date.Format "01-02-2006" }}
|
||||
{{ end }}
|
||||
</span>
|
||||
{{ with .Params.Author }}
|
||||
<span class="post-author">:: {{ . }}</span>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
{{ if .Params.tags }}
|
||||
<span class="post-tags">
|
||||
{{ range .Params.tags }}
|
||||
#<a href="{{ (urlize (printf "tags/%s/" . )) | absLangURL }}">
|
||||
{{- . -}}
|
||||
</a>
|
||||
{{ end }}
|
||||
</span>
|
||||
{{ end }}
|
||||
|
||||
{{ if .Params.Cover }}
|
||||
<img src="{{ .Params.Cover | absURL }}" class="post-cover" alt="{{ .Title | plainify | default " " }}" />
|
||||
{{ end }}
|
||||
|
||||
<div class="post-content">
|
||||
{{ if .Params.showFullContent }}
|
||||
{{ .Content | markdownify }}
|
||||
{{ else if .Description }}
|
||||
{{ .Description | markdownify }}
|
||||
{{ else }}
|
||||
{{ if .Truncated }}
|
||||
{{ .Summary | markdownify }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
{{ if not .Params.showFullContent }}
|
||||
<div>
|
||||
<a class="read-more button"
|
||||
href="{{.RelPermalink}}">{{ $.Site.Params.ReadMore }} →</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</article>
|
||||
{{ partial "collection.html" . }}
|
||||
{{ end }}
|
||||
{{ partial "pagination.html" . }}
|
||||
</div>
|
||||
|
50
layouts/partials/collection.html
Normal file
50
layouts/partials/collection.html
Normal file
@ -0,0 +1,50 @@
|
||||
<article class="post on-list">
|
||||
<h1 class="post-title">
|
||||
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
|
||||
</h1>
|
||||
<div class="post-meta">
|
||||
<span class="post-date">
|
||||
{{ with .Params.daterange }}
|
||||
{{ . }}
|
||||
{{ else }}
|
||||
{{ .Date.Format "01-02-2006" }}
|
||||
{{ end }}
|
||||
</span>
|
||||
{{ with .Params.Author }}
|
||||
<span class="post-author">:: {{ . }}</span>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
{{ if .Params.tags }}
|
||||
<span class="post-tags">
|
||||
{{ range .Params.tags }}
|
||||
#<a href="{{ (urlize (printf "tags/%s/" . )) | absLangURL }}">
|
||||
{{- . -}}
|
||||
</a>
|
||||
{{ end }}
|
||||
</span>
|
||||
{{ end }}
|
||||
|
||||
{{ if .Params.Cover }}
|
||||
<img src="{{ .Params.Cover | absURL }}" class="post-cover" alt="{{ .Title | plainify | default " " }}" />
|
||||
{{ end }}
|
||||
|
||||
<div class="post-content">
|
||||
{{ if .Params.showFullContent }}
|
||||
{{ .Content | markdownify }}
|
||||
{{ else if .Description }}
|
||||
{{ .Description | markdownify }}
|
||||
{{ else }}
|
||||
{{ if .Truncated }}
|
||||
{{ .Summary | markdownify }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
{{ if not .Params.showFullContent }}
|
||||
<div>
|
||||
<a class="read-more button"
|
||||
href="{{.RelPermalink}}">{{ $.Site.Params.ReadMore }} →</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</article>
|
Loading…
x
Reference in New Issue
Block a user