Update section to show default post layout for any non-matching layout. Add homepage section example

This commit is contained in:
Justin Nguyen 2021-01-14 16:28:31 -08:00
parent 8136be7dea
commit 1b08c1579e
3 changed files with 32 additions and 21 deletions

View File

@ -9,17 +9,13 @@ paginate = 10
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 starting with "/#" will be displayed using the
# front matter defined in "homepage/". A collection is displayed for other menu items.
# Only menu items with a url starting with "/#" will be displayed using the
# front matter defined in "homepage/". The standard collection is displayed for other menu items.
singlePageSite = true
homepagePaginateCount = 10 # If you want the homepage to paginate a different numebr of items
[params.twitter]
creator = "@justinnuwin"
site = "@justinnuwin"
[languages]
[languages.en]
title = "Terminal"
@ -35,6 +31,10 @@ paginate = 10
logoHomeLink = "/"
[languages.en.menu]
[[languages.en.menu.main]]
identifier = "homepage-info"
name = "Homepage Section"
url = "#/section"
[[languages.en.menu.main]]
identifier = "about"
name = "About"

View File

@ -0,0 +1,12 @@
+++
title = "Homepage Section"
cover = "img/hello.jpg"
layout = "2col-right"
+++
**Hi there!** This is a section dedicated for a homepage.
There are 3 layouts supported for the homepage sections:
- `2col-right` - The layout for this section with the cover image appearing on the left and the front-matter on the right
- `2col-left` - The layout for this section has the cover image on the right and front-matter on the left
- `default` - The default layout for the section matching the post layout with the image appearing above the front-matter

View File

@ -1,17 +1,3 @@
{{ if eq .Params.Layout "post" }}
{{ if .Params.Cover }}
<img src="{{ .Params.Cover | absURL }}" class="section-cover" alt="{{ .Title | plainify | default " " }}" />
{{ end }}
<div class="post-content">
{{- with .Content -}}
<div>
{{ . | replaceRE "(<h[1-9] id=\"([^\"]+)\".+)(</h[1-9]+>)" `${1}<a href="#${2}" class="hanchor" ariaLabel="Anchor">&#8983;</a> ${3}` | safeHTML }}
</div>
{{- end -}}
</div>
{{ end }}
{{ if in "2col-left 2col-right" .Params.Layout }}
<div class="section-2col section-{{ .Params.Layout | plainify }}">
<div>
@ -25,4 +11,17 @@
{{- end -}}
</div>
</div>
{{ else }}
{{ if .Params.Cover }}
<img src="{{ .Params.Cover | absURL }}" class="section-cover" alt="{{ .Title | plainify | default " " }}" />
{{ end }}
<div class="post-content">
{{- with .Content -}}
<div>
{{ . | replaceRE "(<h[1-9] id=\"([^\"]+)\".+)(</h[1-9]+>)" `${1}<a href="#${2}" class="hanchor" ariaLabel="Anchor">&#8983;</a> ${3}` | safeHTML }}
</div>
{{- end -}}
</div>
{{ end }}