diff options
author | Marcin Zajączkowski <szpak@users.sourceforge.net> | 2020-05-18 19:55:16 +0300 |
---|---|---|
committer | Marcin Zajączkowski <szpak@users.sourceforge.net> | 2020-05-18 20:32:27 +0300 |
commit | 6f5b7d9f0949af19ef08af069cbdde2f04ea53a9 (patch) | |
tree | 6fd3db90ebc4e6a3f490631b153e6ce691a09340 | |
parent | 4c77300eebfb2e5521954edb37ec79afd62fd92f (diff) |
[ZZO] Pinned posts
-rw-r--r-- | README.ko.md | 1 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | exampleSite/config/_default/params.toml | 1 | ||||
-rw-r--r-- | exampleSite/content/en/posts/syntax-highlight.md | 1 | ||||
-rw-r--r-- | layouts/index.html | 6 | ||||
-rw-r--r-- | layouts/partials/summary/card.html | 2 | ||||
-rw-r--r-- | layouts/partials/summary/classic.html | 2 | ||||
-rw-r--r-- | 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 @@ -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 @@ <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 -}}📌 {{- 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")) }} 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 @@ <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 -}}📌 {{- 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")) }} 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 }} <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 -}}📌 {{- 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")) }} |