From 0c80aa9ee5d6178e24163e1431f182232c89222c Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Thu, 15 Apr 2021 10:04:06 +0200 Subject: [PATCH] related articles converted to hugo templating --- layouts/index.html | 29 +---------------- layouts/partials/article_card.html | 28 ++++++++++++++++ layouts/partials/related_articles.html | 44 ++++++-------------------- 3 files changed, 39 insertions(+), 62 deletions(-) create mode 100644 layouts/partials/article_card.html diff --git a/layouts/index.html b/layouts/index.html index 6f37a5f..4aecdd4 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -20,34 +20,7 @@ {{/* pagination */}}
{{ range $pagination }} -
-
-

- {{ .Title }} -

-

- - {{ .Date.Format "2006-01-02" }} - {{ if .Params.tags }} - | - - {{ range .Params.tags }} - #{{ . }} - {{ end }} - {{ end }} -

- {{ if .Site.Params.imageInArticlePreview }} - {{ if .Params.Image }} - - {{ end }} - {{end}} -
-

{{ .Summary }}

-

Continue reading 

-
-
-
-
+ {{- partial "article_card.html" . -}} {{ end }}
diff --git a/layouts/partials/article_card.html b/layouts/partials/article_card.html new file mode 100644 index 0000000..aaf07d3 --- /dev/null +++ b/layouts/partials/article_card.html @@ -0,0 +1,28 @@ +
+
+

+ {{ .Title }} +

+

+ + {{ .Date.Format "2006-01-02" }} + {{ if .Params.tags }} + | + + {{ range .Params.tags }} + #{{ . }} + {{ end }} + {{ end }} +

+ {{ if .Site.Params.imageInArticlePreview }} + {{ if .Params.Image }} + + {{ end }} + {{end}} +
+

{{ .Summary }}

+

Continue reading 

+
+
+
+
diff --git a/layouts/partials/related_articles.html b/layouts/partials/related_articles.html index 2faad2f..2379fb6 100644 --- a/layouts/partials/related_articles.html +++ b/layouts/partials/related_articles.html @@ -1,40 +1,16 @@ {{ if and (.Site.Params.enableRelatedArticles | default false) .Params.tags }} + {{ $postsList := + where ( + where site.RegularPages "Params.tags" "!=" nil + ) "Params.tags" "intersect" .Params.tags + }}

More posts like this

- +
+ {{ range first (.Site.Params.relatedArticlesNum | default 2) $postsList }} + {{- partial "article_card.html" . -}} + {{ end }} +
- {{- partial "js_paginator.html" . -}} - {{ end }}