diff options
author | Regis Philibert <login@regisphilibert.com> | 2019-10-02 18:57:39 +0300 |
---|---|---|
committer | Regis Philibert <login@regisphilibert.com> | 2019-10-02 18:57:39 +0300 |
commit | ed82213fe11961b66e72b49263eaebbe9f4a1ab6 (patch) | |
tree | ff886dd58e8fae17f462b6b7102bfdad4ea88584 /layouts | |
parent | 37513fde6d39d66e2aa45f2353df7e028401c4be (diff) |
Refactor Authors list page pending taxonomy specimprove-hugo-logic
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/author/author_articles_list.html | 71 | ||||
-rw-r--r-- | layouts/partials/func/GetArticleAuthors.html | 39 | ||||
-rw-r--r-- | layouts/partials/func/GetAuthorArticles.html | 4 |
3 files changed, 65 insertions, 49 deletions
diff --git a/layouts/partials/author/author_articles_list.html b/layouts/partials/author/author_articles_list.html index c1c08bb..b3b74ca 100644 --- a/layouts/partials/author/author_articles_list.html +++ b/layouts/partials/author/author_articles_list.html @@ -1,57 +1,30 @@ <section class="section nartrow author-alc-section"> <div id="articlesList" class="articles-list-container show-details author-alc"> - {{ $scratch :=newScratch }} - {{ $scratch.Set "authorName" .Page.Params.name }} - {{ $scratch.Set "biggerFirst" true }} - {{ $scratch.Set "biggerPlaced" false }} + {{ $articles := partial "func/GetAuthorArticles" . }} <div class="post-row-alt"> - {{ range $index, $article := where .Site.RegularPages "Type" "post" }} - - {{ $scratch.Set "authorMatch" false }} - {{ range $author := $article.Params.authors }} - {{ $authorPage := $.Site.GetPage $author }} - - {{ if eq $authorPage.Params.name ($scratch.Get "authorName") }} - {{ $scratch.Set "authorMatch" true }} - {{ end }} - {{ end }} - - {{ $counter := mod $index 2 }} - {{ if eq ($scratch.Get "authorMatch") true }} - <a href="{{ $article.Permalink }}" class="article-link"> - <div class="article-data-outer"> - <div class="image-container"> - <img src="{{ $article.Params.hero }}" class="article-image" /> - </div> - <div class="article-data"> - <h2 class="article-title"> - {{ $article.Params.title }} - </h2> - <p class="article-excerpt"> - {{ $article.Params.excerpt }} - </p> - <div class="article-metadata"> - {{ $article.Date.Format "January 2, 2006" }}{{ if $article.Params.timetoread }} • {{ $article.Params.timetoread }} min read{{ end }} - </div> - </div> - </div> - </a> - {{ $counter := mod (add $index 1) 2 }} - {{ $len := (where .Pages "Type" "posts") }} - {{ end }} - {{ end }} + {{ range $index, $article := $articles }} + {{ $counter := mod $index 2 }} + <a href="{{ $article.Permalink }}" class="article-link"> + <div class="article-data-outer"> + <div class="image-container"> + <img src="{{ $article.Params.hero }}" class="article-image" /> + </div> + <div class="article-data"> + <h2 class="article-title"> + {{ $article.Params.title }} + </h2> + <p class="article-excerpt"> + {{ $article.Params.excerpt }} + </p> + <div class="article-metadata"> + {{ $article.Date.Format "January 2, 2006" }}{{ if $article.Params.timetoread }} • {{ $article.Params.timetoread }} min read{{ end }} + </div> + </div> + </div> + </a> + {{ end }} </div> </div> - - <nav aria-label="Page navigation"> - <ul class="pagination"> - <li class="page-item active"><a href="/" class="page-link">1</a></li> - <li class="page-item"><a href="/page/2/" class="page-link">2</a></li> - <li class="page-item"><a href="/page/3/" class="page-link">3</a></li> - <li class="page-item"><a href="/page/2/" rel="next" class="page-link page-next">Next</a></li> - </ul> - </nav> - </section> {{ $script := resources.Get "js/toggleBorder.js" }} diff --git a/layouts/partials/func/GetArticleAuthors.html b/layouts/partials/func/GetArticleAuthors.html new file mode 100644 index 0000000..c6041e4 --- /dev/null +++ b/layouts/partials/func/GetArticleAuthors.html @@ -0,0 +1,39 @@ +{{/* + GetArticle Authors + Retrieve the authors assigned to a given article + + @author @regisphilibert + + @context Page (.) The article in quest + + @access public + + @return Slice + - String (.name) + - String (.URL) + - String (.name) + - String (.firstname) + + @example - Go Template + {{ $authors := partialCached "func/GetArticleAuthors" . .File.UniqueID }} +*/}} +{{ $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 diff --git a/layouts/partials/func/GetAuthorArticles.html b/layouts/partials/func/GetAuthorArticles.html new file mode 100644 index 0000000..318dfe6 --- /dev/null +++ b/layouts/partials/func/GetAuthorArticles.html @@ -0,0 +1,4 @@ +{{ $articles := slice }} +{{ $articles = where .Site.RegularPages "Type" "post" }} +{{ $articles = where $articles "Params.authors" "intersect" (slice .File.Path) }} +{{ return $articles }}
\ No newline at end of file |