Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pinned posts #272

Merged
merged 1 commit into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ notAllowedTypesInHome = ["contact", "talks", "about", "showcase"] # not allowed
notAllowedTypesInHomeSidebar = ["about", "archive", "showcase"] # not allowed page types in home page sidebar(recent post titles).
notAllowedTypesInArchive = ["about", "talks", "showcase"] # not allowed page types in archive page
notAllowedTypesInHomeFeed = ["about", "archive", "contact", "talks", "showcase", "publication", "presentation", "resume", "gallery"]
enablePinnedPosts = true # show pinned posts first in the main view

viewportSize = "normal" # widest, wider, wide, normal, narrow
enableUiAnimation = true
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ notAllowedTypesInHome = ["contact", "talks", "about", "showcase"] # not allowed
notAllowedTypesInHomeSidebar = ["about", "archive", "showcase"] # not allowed page types in home page sidebar(recent post titles).
notAllowedTypesInArchive = ["about", "talks", "showcase"] # not allowed page types in archive page
notAllowedTypesInHomeFeed = ["about", "archive", "contact", "talks", "showcase", "publication", "presentation", "resume", "gallery"]
enablePinnedPosts = true # show pinned posts first in the main view

viewportSize = "normal" # widest, wider, wide, normal, narrow
enableUiAnimation = true
Expand Down
1 change: 1 addition & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ notAllowedTypesInHome = ["contact", "talks", "about", "showcase", "publication",
notAllowedTypesInHomeSidebar = ["about", "archive", "showcase", "publication", "presentation", "resume"]
notAllowedTypesInArchive = ["about", "talks", "showcase", "publication", "presentation", "resume"]
notAllowedTypesInHomeFeed = ["about", "archive", "contact", "talks", "showcase", "publication", "presentation", "resume", "gallery"]
enablePinnedPosts = true

viewportSize = "normal" # widest, wider, wide, normal, narrow
enableUiAnimation = true
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/en/posts/syntax-highlight.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ enableToc: true
enableTocContent: false
author: Jeus
authorEmoji: 🎅
pinned: true
tags:
- hugo
series:
Expand Down
6 changes: 6 additions & 0 deletions layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
{{ range $.Param "notAllowedTypesInHome" }}
{{ $filteredPages = (where $filteredPages "Type" "!=" (lower .)) }}
{{ end }}
{{ $filteredPagesPinned := slice }}
{{ if .Site.Params.enablePinnedPosts }}
{{ $filteredPagesPinned = (where $filteredPages "Params.pinned" "==" true) }}
{{ end }}
{{ $filteredPages := $filteredPages | intersect (where $filteredPages "Params.pinned" "!=" true) }}
{{ $filteredPages := $filteredPages | union ($filteredPagesPinned) }}
{{ $paginator := .Paginate $filteredPages }}
{{ range $paginator.Pages }}
{{ .Render "summary" }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/summary/card.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<article class="summary-card" data-ani="{{ $.Site.Params.enableUiAnimation | default "true" }}">
<header>
<h5 class="title h5"><a href='{{ .Permalink }}'> {{ .Title }}</a> </h5>
<h5 class="title h5"><a href='{{ .Permalink }}'>{{- with .Params.pinned -}}📌&nbsp;{{- end -}}{{ .Title }}</a> </h5>
<h6 class="subtitle caption">
<time title="{{ i18n "tooltip-written" }}" dir="{{ if ne ($.Param "languagedir") "rtl" }}ltr{{ else }}rtl{{ end }}">📅{{ .Date.Format (i18n "summary-dateformat") }} </time>
{{ if ne (.Date.Format (i18n "summary-dateformat")) (.Lastmod.Format (i18n "summary-dateformat")) }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/summary/classic.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<div class="summary-classic__content">
<header>
<h5 class="title h5"><a href='{{ .Permalink }}'> {{ .Title }}</a> </h5>
<h5 class="title h5"><a href='{{ .Permalink }}'>{{- with .Params.pinned -}}📌&nbsp;{{- end -}}{{ .Title }}</a> </h5>
<h6 class="subtitle caption">
<time title="{{ i18n "tooltip-written" }}" dir="{{ if ne ($.Param "languagedir") "rtl" }}ltr{{ else }}rtl{{ end }}">📅&nbsp;{{ .Date.Format (i18n "summary-dateformat") }} </time>
{{ if ne (.Date.Format (i18n "summary-dateformat")) (.Lastmod.Format (i18n "summary-dateformat")) }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/summary/compact.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ $params := .Params }}
<div class="summary-compact__meta">
<header>
<h5 class="title h6"><a href='{{ .Permalink }}'> {{ .Title }}</a> </h5>
<h5 class="title h6"><a href='{{ .Permalink }}'>{{- with .Params.pinned -}}📌&nbsp;{{- end -}}{{ .Title }}</a> </h5>
<h6 class="subtitle caption">
<time title="{{ i18n "tooltip-written" }}" dir="{{ if ne ($.Param "languagedir") "rtl" }}ltr{{ else }}rtl{{ end }}">📅 {{ .Date.Format (i18n "summary-dateformat") }} </time>
{{ if ne (.Date.Format (i18n "summary-dateformat")) (.Lastmod.Format (i18n "summary-dateformat")) }}
Expand Down