From 6f5b7d9f0949af19ef08af069cbdde2f04ea53a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Mon, 18 May 2020 18:55:16 +0200 Subject: [PATCH] [ZZO] Pinned posts --- README.ko.md | 1 + README.md | 1 + exampleSite/config/_default/params.toml | 1 + exampleSite/content/en/posts/syntax-highlight.md | 1 + layouts/index.html | 6 ++++++ layouts/partials/summary/card.html | 2 +- layouts/partials/summary/classic.html | 2 +- layouts/partials/summary/compact.html | 2 +- 8 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.ko.md b/README.ko.md index 8374bde..63082a5 100644 --- a/README.ko.md +++ b/README.ko.md @@ -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 diff --git a/README.md b/README.md index c34fc81..b18ff76 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 12f2aae..7b2d146 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -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 diff --git a/exampleSite/content/en/posts/syntax-highlight.md b/exampleSite/content/en/posts/syntax-highlight.md index 17508ef..c95f1f5 100644 --- a/exampleSite/content/en/posts/syntax-highlight.md +++ b/exampleSite/content/en/posts/syntax-highlight.md @@ -8,6 +8,7 @@ enableToc: true enableTocContent: false author: Jeus authorEmoji: 🎅 +pinned: true tags: - hugo series: diff --git a/layouts/index.html b/layouts/index.html index c3f724c..c0fe661 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -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" }} diff --git a/layouts/partials/summary/card.html b/layouts/partials/summary/card.html index fa3697a..80e9446 100644 --- a/layouts/partials/summary/card.html +++ b/layouts/partials/summary/card.html @@ -1,6 +1,6 @@
-
{{ .Title }}
+
{{- with .Params.pinned -}}📌 {{- end -}}{{ .Title }}
{{ if ne (.Date.Format (i18n "summary-dateformat")) (.Lastmod.Format (i18n "summary-dateformat")) }} diff --git a/layouts/partials/summary/classic.html b/layouts/partials/summary/classic.html index 4d0bf85..e43222c 100644 --- a/layouts/partials/summary/classic.html +++ b/layouts/partials/summary/classic.html @@ -17,7 +17,7 @@
-
{{ .Title }}
+
{{- with .Params.pinned -}}📌 {{- end -}}{{ .Title }}
{{ if ne (.Date.Format (i18n "summary-dateformat")) (.Lastmod.Format (i18n "summary-dateformat")) }} diff --git a/layouts/partials/summary/compact.html b/layouts/partials/summary/compact.html index 7c9d94b..a815fdc 100644 --- a/layouts/partials/summary/compact.html +++ b/layouts/partials/summary/compact.html @@ -3,7 +3,7 @@ {{ $params := .Params }}
-
{{ .Title }}
+
{{- with .Params.pinned -}}📌 {{- end -}}{{ .Title }}
{{ if ne (.Date.Format (i18n "summary-dateformat")) (.Lastmod.Format (i18n "summary-dateformat")) }}