Skip to content

Commit

Permalink
Add the ability to display an optional pinned post at the top of the …
Browse files Browse the repository at this point in the history
…index
  • Loading branch information
nnja committed Sep 15, 2018
1 parent 2d75998 commit 39647cf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ disqusShortname = "bilberry-hugo-theme"
showHeaderLanguageChooser = true

# Content configuration
# Enable an optional pinned page to display at the top of the index
# pinnedPost = "/content/github/"

# enable automatical localization of the article's PublishedDate with momentjs
enableMomentJs = true

Expand Down
15 changes: 8 additions & 7 deletions layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{{ define "main" }}

{{ if .Site.Params.pinnedPost }}
{{ range first 1 (where .Data.Pages "URL" .Site.Params.pinnedPost) }}
{{ partial "article-wrapper" . }}
{{end}}
{{end}}

{{ $paginator := .Paginate (where .Data.Pages "Type" "ne" "page") (index .Site.Params "paginate" | default 7) }}
{{ range where .Paginator.Pages "Type" "ne" "page" }}
<div class="article-wrapper u-cf">
{{ if or (fileExists (print "layouts/partials/content-type/" .Type ".html") ) (fileExists (print "themes/bilberry-hugo-theme/layouts/partials/content-type/" .Type ".html")) }}
{{ partial (print "content-type/" .Type) . }}
{{ else }}
{{ partial "content-type/article" . }}
{{ end }}
</div>
{{ partial "article-wrapper" . }}
{{ end }}

{{ partial "paginator" . }}
Expand Down
9 changes: 9 additions & 0 deletions layouts/partials/article-wrapper.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{ with . }}
<div class="article-wrapper u-cf">
{{ if or (fileExists (print "layouts/partials/content-type/" .Type ".html") ) (fileExists (print "themes/bilberry-hugo-theme/layouts/partials/content-type/" .Type ".html")) }}
{{ partial (print "content-type/" .Type) . }}
{{ else }}
{{ partial "content-type/article" . }}
{{ end }}
</div>
{{end}}

0 comments on commit 39647cf

Please sign in to comment.