From 889f30f41ae374ee765398859cd305f14159f39e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20Cora=C3=A7=C3=A3o?= Date: Fri, 30 Dec 2022 19:30:16 +0000 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20custom=20landin?= =?UTF-8?q?g=20page=20and=20recent=20articles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exampleSite/config/_default/params.toml | 2 +- .../partials/recent-articles-demo.html | 24 +++---------------- .../recent-articles-cardview-fullwidth.html | 11 +++++++++ .../partials/recent-articles-cardview.html | 9 +++++++ layouts/partials/recent-articles-list.html | 9 +++++++ layouts/partials/recent-articles.html | 23 ++++-------------- 6 files changed, 38 insertions(+), 40 deletions(-) create mode 100644 layouts/partials/recent-articles-cardview-fullwidth.html create mode 100644 layouts/partials/recent-articles-cardview.html create mode 100644 layouts/partials/recent-articles-list.html diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index bb020ed7..7ec92035 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -36,7 +36,7 @@ defaultBackgroundImage = "/img/iceland.jpg" showRecentItems = 10 showMoreLink = true showMoreLinkDest = "docs" - cardView = true + cardView = false cardViewScreenWidth = false layoutBackgroundBlur = true # only used when layout equals background diff --git a/exampleSite/layouts/partials/recent-articles-demo.html b/exampleSite/layouts/partials/recent-articles-demo.html index cf73aeed..2b91b85b 100644 --- a/exampleSite/layouts/partials/recent-articles-demo.html +++ b/exampleSite/layouts/partials/recent-articles-demo.html @@ -18,33 +18,15 @@
-
- {{ range first $recentArticles (.Paginate (where .Site.RegularPages "Type" "in" - .Site.Params.mainSections)).Pages }} - {{ partial "article-link-card.html" . }} - {{ end }} -
+ {{ partial "recent-articles-cardview-fullwidth.html" . }}
{{ if .Site.Params.homepage.showMoreLink | default false }} diff --git a/layouts/partials/recent-articles-cardview-fullwidth.html b/layouts/partials/recent-articles-cardview-fullwidth.html new file mode 100644 index 00000000..9542df83 --- /dev/null +++ b/layouts/partials/recent-articles-cardview-fullwidth.html @@ -0,0 +1,11 @@ +{{ $recentArticles := 5 }} +{{ $recentArticles = .Site.Params.homepage.showRecentItems }} + +
+ {{ range first $recentArticles (.Paginate (where .Site.RegularPages "Type" "in" + .Site.Params.mainSections)).Pages }} + {{ partial "article-link-card.html" . }} + {{ end }} +
\ No newline at end of file diff --git a/layouts/partials/recent-articles-cardview.html b/layouts/partials/recent-articles-cardview.html new file mode 100644 index 00000000..ff531a3f --- /dev/null +++ b/layouts/partials/recent-articles-cardview.html @@ -0,0 +1,9 @@ +{{ $recentArticles := 5 }} +{{ $recentArticles = .Site.Params.homepage.showRecentItems }} + +
+ {{ range first $recentArticles (.Paginate (where .Site.RegularPages "Type" "in" + .Site.Params.mainSections)).Pages }} + {{ partial "article-link-card.html" . }} + {{ end }} +
\ No newline at end of file diff --git a/layouts/partials/recent-articles-list.html b/layouts/partials/recent-articles-list.html new file mode 100644 index 00000000..f9515478 --- /dev/null +++ b/layouts/partials/recent-articles-list.html @@ -0,0 +1,9 @@ +{{ $recentArticles := 5 }} +{{ $recentArticles = .Site.Params.homepage.showRecentItems }} + +
+ {{ range first $recentArticles (.Paginate (where .Site.RegularPages "Type" "in" .Site.Params.mainSections)).Pages + }} + {{ partial "article-link.html" . }} + {{ end }} +
\ No newline at end of file diff --git a/layouts/partials/recent-articles.html b/layouts/partials/recent-articles.html index 72eace39..41744d49 100644 --- a/layouts/partials/recent-articles.html +++ b/layouts/partials/recent-articles.html @@ -6,25 +6,12 @@ {{ end }}

{{ i18n "shortcode.recent_articles" | emojify }}

-{{ if .Site.Params.homepage.cardView | default false }} -{{ if .Site.Params.homepage.cardViewScreenWidth | default false }} -
- {{ else }} -
- {{ end }} - {{ range first $recentArticles (.Paginate (where .Site.RegularPages "Type" "in" - .Site.Params.mainSections)).Pages }} - {{ partial "article-link-card.html" . }} - {{ end }} -
+{{ if and .Site.Params.homepage.cardView (not .Site.Params.homepage.cardViewScreenWidth) | default false }} + {{ partial "recent-articles-cardview.html" . }} +{{ else if and .Site.Params.homepage.cardView .Site.Params.homepage.cardViewScreenWidth | default false }} + {{ partial "recent-articles-cardview-fullwidth.html" . }} {{ else }} -
- {{ range first $recentArticles (.Paginate (where .Site.RegularPages "Type" "in" .Site.Params.mainSections)).Pages - }} - {{ partial "article-link.html" . }} - {{ end }} -
+ {{ partial "recent-articles-list.html" . }} {{ end }} {{ if .Site.Params.homepage.showMoreLink | default false }}