diff options
author | mountainbug95 <tannersmithtn95@gmail.com> | 2019-09-26 23:31:04 +0300 |
---|---|---|
committer | mountainbug95 <tannersmithtn95@gmail.com> | 2019-09-26 23:31:04 +0300 |
commit | ccbd14c1c60d274cc2b79225f17760de48a9b287 (patch) | |
tree | a1fe2b60bcff292c8b379ac5c8efc3c248c27ec4 /layouts | |
parent | 772627c4d778df0530a7189db31dc9da1a6daf97 (diff) |
Refactor posts to reference authors by file paths
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/article/article_authors.html | 28 | ||||
-rw-r--r-- | layouts/partials/author/author_articles_list.html | 3 |
2 files changed, 19 insertions, 12 deletions
diff --git a/layouts/partials/article/article_authors.html b/layouts/partials/article/article_authors.html index 3d0cac0..915eda5 100644 --- a/layouts/partials/article/article_authors.html +++ b/layouts/partials/article/article_authors.html @@ -1,15 +1,18 @@ {{ $scratch := newScratch }} {{ $scratch.Set "numAuthors" 0 }} -{{ range .Params.authors }} - {{ $scratch.Set "numAuthors" (add ($scratch.Get "numAuthors") 1) }} -{{ end }} + +{{ $authors := .Params.authors }} + +{{ $scratch.Set "numAuthors" (len $authors) }} +{{ $scratch.Set "authors" $authors }} {{ if eq ($scratch.Get "numAuthors") 1 }} {{ range $author := where .Site.RegularPages "Type" "author" }} - {{ $firstAuthor := index $.Params.authors 0 }} - {{ if eq $author.Params.name $firstAuthor.name }} + {{ $authorPath := index ($scratch.Get "authors") 0 }} + {{ $firstAuthor := .Site.GetPage $authorPath }} + {{ if eq $author.Params.name $firstAuthor.Params.name }} <a href="{{ $author.Permalink }}" class="article-author-link"> {{ if $author.Params.avatar }} <div class="article-author-avatar"> @@ -33,8 +36,9 @@ {{ $scratch.Set "authors" .Params.authors }} {{ range $index, $author := where .Site.RegularPages "Type" "author" }} {{ $scratch.Set "nameHold" $author.Params.name }} - {{ range $authorCompare := $scratch.Get "authors" }} - {{ if eq $authorCompare.name ($scratch.Get "nameHold") }} + {{ range $authorPath := $scratch.Get "authors" }} + {{ $authorCompare := $.Site.GetPage $authorPath }} + {{ if eq $authorCompare.Params.name ($scratch.Get "nameHold") }} {{ $scratch.Set "matches" true }} {{ end }} {{ end }} @@ -52,8 +56,9 @@ {{ $scratch.Set "authors" .Params.authors }} {{ range $index, $author := where .Site.RegularPages "Type" "author" }} {{ $scratch.Set "nameHold" $author.Params.name }} - {{ range $authorCompare := $scratch.Get "authors" }} - {{ if eq $authorCompare.name ($scratch.Get "nameHold") }} + {{ range $authorPath := $scratch.Get "authors" }} + {{ $authorCompare := $.Site.GetPage $authorPath }} + {{ if eq $authorCompare.Params.name ($scratch.Get "nameHold") }} {{ $scratch.Set "matches" true }} {{ end }} {{ end }} @@ -75,8 +80,9 @@ {{ $scratch.Set "authors" .Params.authors }} {{ range $index, $author := where .Site.RegularPages "Type" "author" }} {{ $scratch.Set "nameHold" $author.Params.name }} - {{ range $authorCompare := $scratch.Get "authors" }} - {{ if eq $authorCompare.name ($scratch.Get "nameHold") }} + {{ range $authorPath := $scratch.Get "authors" }} + {{ $authorCompare := $.Site.GetPage $authorPath }} + {{ if eq $authorCompare.Params.name ($scratch.Get "nameHold") }} {{ $scratch.Set "matches" true }} {{ end }} {{ end }} diff --git a/layouts/partials/author/author_articles_list.html b/layouts/partials/author/author_articles_list.html index 8987bfa..bff0149 100644 --- a/layouts/partials/author/author_articles_list.html +++ b/layouts/partials/author/author_articles_list.html @@ -1,4 +1,5 @@ <section class="section nartrow"> {{ $paginator := .Paginate (where .Site.RegularPages "Type" "post") }} -{{ $paginator }} +{{ $test := .Site.GetPage "authors/dennis-brotzky" }} +{{ $test.Params }} </section>
\ No newline at end of file |