Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/forestryio/hugo-theme-novela.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRegis Philibert <login@regisphilibert.com>2019-10-02 18:29:57 +0300
committerRegis Philibert <login@regisphilibert.com>2019-10-02 18:29:57 +0300
commit37513fde6d39d66e2aa45f2353df7e028401c4be (patch)
tree892f9e0e2b5bb2d6ec803a3ec500f2d7aa9819bc
parent6eac8d46c981ccb19afbfd6caaa7104c10df5d8c (diff)
Refactor article list
-rw-r--r--layouts/partials/article/article_authors.html2
-rw-r--r--layouts/partials/article/article_hero.html2
-rw-r--r--layouts/partials/articles/articles_list.html23
-rw-r--r--layouts/partials/func/GetAuthors.html20
4 files changed, 13 insertions, 34 deletions
diff --git a/layouts/partials/article/article_authors.html b/layouts/partials/article/article_authors.html
index fc1d29f..66c39b1 100644
--- a/layouts/partials/article/article_authors.html
+++ b/layouts/partials/article/article_authors.html
@@ -1,5 +1,5 @@
-{{ $authors := partialCached "func/GetAuthors" . .File.UniqueID }}
+{{ $authors := partialCached "func/GetArticleAuthors" . .File.UniqueID }}
{{ if eq (len $authors) 1 }}
{{ with $author := index $authors 0 }}
<a href="{{ .URL }}" class="article-author-link">
diff --git a/layouts/partials/article/article_hero.html b/layouts/partials/article/article_hero.html
index d393288..ae85203 100644
--- a/layouts/partials/article/article_hero.html
+++ b/layouts/partials/article/article_hero.html
@@ -6,7 +6,7 @@
<div class="article-meta">
{{ partial "article/article_authors.html" . }}
{{ .Page.Date.Format "January 2, 2006" }}
- {{ if .Page.Params.timetoread }} • {{ .Page.Params.timetoread }} min read{{ end }}
+ {{ with .Page.Params.timetoread }} • {{ . }} min read{{ end }}
</div>
</div>
</header>
diff --git a/layouts/partials/articles/articles_list.html b/layouts/partials/articles/articles_list.html
index 9d6d8b4..1109650 100644
--- a/layouts/partials/articles/articles_list.html
+++ b/layouts/partials/articles/articles_list.html
@@ -1,24 +1,23 @@
<section class="section nartrow">
<div id="articlesList" class="articles-list-container show-details">
{{ $paginator := .Paginate (where .Site.RegularPages "Type" "post") }}
- {{ $scratch :=newScratch }}
- {{ $scratch.Set "biggerFirst" true }}
- {{ $scratch.Set "biggerPlaced" false }}
+ {{ $biggerFirst := true }}
+ {{ $biggerPlaced := false }}
{{ range $index, $article := $paginator.Pages }}
{{ $counter := mod $index 2 }}
- {{ if eq $counter 0 }}
+ {{ if not $counter }}
<div class="post-row">
{{ end }}
<a href="{{ $article.Permalink }}" class="article-link"
- {{ if and (eq ($scratch.Get "biggerFirst") true) (eq ($scratch.Get "biggerPlaced") false) }}
+ {{ if and (eq ($biggerFirst) true) (eq ($biggerPlaced) false) }}
{{ if eq $counter 0 }}
id="article-link-bigger"
- {{ $scratch.Set "biggerPlaced" true }}
+ {{ $biggerPlaced = true }}
{{ end }}
- {{ else if and (eq ($scratch.Get "biggerFirst") false) (eq ($scratch.Get "biggerPlaced") false) }}
+ {{ else if and (not $biggerFirst) (not $biggerPlaced) }}
{{ if ne $counter 0 }}
id="article-link-bigger"
- {{ $scratch.Set "biggerPlaced" true }}
+ {{ $biggerPlaced = true }}
{{ end }}
{{ end }}>
<div class="article-data-outer">
@@ -42,11 +41,11 @@
{{ $len := (where .Pages "Type" "posts") }}
{{ if or (eq $counter 0) (eq (add $index 1) $len) }}
</div>
- {{ $scratch.Set "biggerPlaced" false }}
- {{ if eq ($scratch.Get "biggerFirst") true }}
- {{ $scratch.Set "biggerFirst" false }}
+ {{ $biggerPlaced = false }}
+ {{ if $biggerFirst }}
+ {{ $biggerFirst = false }}
{{ else }}
- {{ $scratch.Set "biggerFirst" true }}
+ {{ $biggerFirst = true }}
{{ end }}
{{ end }}
{{ end }}
diff --git a/layouts/partials/func/GetAuthors.html b/layouts/partials/func/GetAuthors.html
deleted file mode 100644
index b24641c..0000000
--- a/layouts/partials/func/GetAuthors.html
+++ /dev/null
@@ -1,20 +0,0 @@
-{{ $authors := slice }}
-{{ with .Params.authors }}
- {{ range . }}
- {{ with site.GetPage . }}
- {{ $firstname := "" }}
- {{ $name := "" }}
- {{ $avatar := false }}
- {{ with .Params.name }}
- {{ $name = . }}
- {{ $firstname = index (split . " ") 0 }}
- {{ end }}
- {{ with .Params.avatar }}
- {{ $avatar = . }}
- {{ end }}
- {{ $authors = $authors | append (dict "URL" .RelPermalink "name" $name "firstname" $firstname "avatar" $avatar) }}
- {{ end }}
- {{ end }}
-{{ end }}
-
-{{ return $authors }} \ No newline at end of file