From 0c92c7b71a25ea4cbe64e23b8a84b35f4d848150 Mon Sep 17 00:00:00 2001 From: Dmitry Kolosov Date: Thu, 23 Dec 2021 21:56:08 +0300 Subject: [PATCH] add hidden page param #124 --- README.md | 8 ++++++-- exampleSite/content/post/hidden-post.md | 12 ++++++++++++ exampleSiteMultilingual/content/post/hidden-post.md | 12 ++++++++++++ .../content/post/hidden-post.pl.md | 12 ++++++++++++ layouts/_default/list.html | 4 ++-- layouts/_default/rss.xml | 2 +- layouts/_default/taxonomy.html | 3 ++- layouts/index.html | 2 +- 8 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 exampleSite/content/post/hidden-post.md create mode 100644 exampleSiteMultilingual/content/post/hidden-post.md create mode 100644 exampleSiteMultilingual/content/post/hidden-post.pl.md diff --git a/README.md b/README.md index 0e3db84..78b376a 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Anubis is a simple minimalist theme for [Hugo blog engine](https://gohugo.io/). - Utteranc.es - RSS feeds - Hiding posts from the RSS feed +- Hidden posts (available only by link) - Translations (en, ru, fr, pl) - Custom CSS/JS - Multilingual mode @@ -192,10 +193,13 @@ Based on environment. For production — allow all, for other — disallow all. ### Favorite posts -To mark posts as favorite just add `favorite: true` in post's front matter. It adds a "★" icon nearby post's title. +Add `favorite: true` to post front matter. It adds a "★" icon nearby post's title. ### Hiding posts from RSS -To hide a post from the RSS feed, just add `disable_feed: true` to its front matter. +Add `disable_feed: true` to post front matter. + +### Make post available only by link +Add `hidden: true` to post front matter. Post also is not available in RSS feed. ### Pagination on post single page Enabled by `paginationSinglePost` param in `params` section of config. diff --git a/exampleSite/content/post/hidden-post.md b/exampleSite/content/post/hidden-post.md new file mode 100644 index 0000000..4239564 --- /dev/null +++ b/exampleSite/content/post/hidden-post.md @@ -0,0 +1,12 @@ ++++ +author = "Dmitry Kolosov" +title = "Hidden Post" +date = "2021-12-24" +description = "Post available only by link" +tags = [ + "privacy" +] +hidden = true ++++ + +This is hidden post \ No newline at end of file diff --git a/exampleSiteMultilingual/content/post/hidden-post.md b/exampleSiteMultilingual/content/post/hidden-post.md new file mode 100644 index 0000000..4239564 --- /dev/null +++ b/exampleSiteMultilingual/content/post/hidden-post.md @@ -0,0 +1,12 @@ ++++ +author = "Dmitry Kolosov" +title = "Hidden Post" +date = "2021-12-24" +description = "Post available only by link" +tags = [ + "privacy" +] +hidden = true ++++ + +This is hidden post \ No newline at end of file diff --git a/exampleSiteMultilingual/content/post/hidden-post.pl.md b/exampleSiteMultilingual/content/post/hidden-post.pl.md new file mode 100644 index 0000000..4239564 --- /dev/null +++ b/exampleSiteMultilingual/content/post/hidden-post.pl.md @@ -0,0 +1,12 @@ ++++ +author = "Dmitry Kolosov" +title = "Hidden Post" +date = "2021-12-24" +description = "Post available only by link" +tags = [ + "privacy" +] +hidden = true ++++ + +This is hidden post \ No newline at end of file diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 02500a2..2f6d7c4 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -5,11 +5,11 @@

{{ i18n .Title }}

- {{ $pages := where .Pages "Type" "in" site.Params.mainSections }} + {{ $pages := where (where .Pages "Type" "in" site.Params.mainSections) "Params.hidden" "!=" true}} {{ range $pages }}
-
+

{{ trim .Title " " }}

{{ partial "post-language-switcher.html" . }}
diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index cb728d9..cc620f4 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -1,6 +1,6 @@ {{- $pctx := . -}} {{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} -{{- $pages := where $pctx.RegularPages ".Params.disable_feed" "!=" true -}} +{{- $pages := where (where $pctx.RegularPages ".Params.disable_feed" "!=" true) "Params.hidden" "!=" true -}} {{- $limit := .Site.Config.Services.RSS.Limit -}} {{- if ge $limit 1 -}} {{- $pages = $pages | first $limit -}} diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html index c31cfb9..9c04382 100644 --- a/layouts/_default/taxonomy.html +++ b/layouts/_default/taxonomy.html @@ -3,7 +3,8 @@ - {{ range .Paginator.Pages }} + {{ $pages := where .Pages "Params.hidden" "!=" true }} + {{ range (.Paginate $pages).Pages }} {{ partial "post-summary.html" . }} {{ end }} {{ partial "pagination.html" . }} diff --git a/layouts/index.html b/layouts/index.html index ed4e128..44f2764 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -4,7 +4,7 @@
- {{ $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} + {{ $pages := where (where site.RegularPages "Type" "in" site.Params.mainSections) "Params.hidden" "!=" true }} {{ range (.Paginate $pages).Pages }} {{ partial "post-summary.html" . }} {{ end }}