Skip to content

Commit

Permalink
Exceprt tag update (#1514)
Browse files Browse the repository at this point in the history
* done

* add author

* Revert "done"

This reverts commit 87fb4d3.

* handle multiple authors (#1516)

---------

Co-authored-by: Alisa <[email protected]>
  • Loading branch information
deepu105 and alisaduncan authored Jul 9, 2024
1 parent a6ae672 commit 19d1e64
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions _source/_plugins/excerpt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,25 @@ def render(context)

if !post.nil?
title = post['title']
# one day figure out how to add author
# author_id = post['author']
# author = context.registers[:site].data['authors'][author_id]
# avatar = author['avatar']
# display_name = author['full_name']
author_content = ""

if !post['author'].kind_of?(Array)
author_id = post['author']

author = context.registers[:site].data['authors'][author_id]
avatar = author['avatar']
display_name = author['full_name']
img=Liquid::Template.parse("{% img '#{avatar}' alt:'avatar-#{avatar}' class:BlogPost-avatar %}").render(context)
author_content = %(<div class="BlogPost-attribution">
<a href='/blog/authors/#{author_id}/'>
#{img}
</a>
<span class="BlogPost-author">
<a href='/blog/authors/#{author_id}/'>#{display_name}</a>
</span>
</div>)
end

description = post['description']

if (description.nil?)
Expand All @@ -29,6 +43,7 @@ def render(context)
<span>#{title}</span>
</a>
<p>#{description}</p>
<div>#{author_content}</div>
</article>)
else
%(<div class="link-container">
Expand Down

0 comments on commit 19d1e64

Please sign in to comment.