Skip to content

Commit

Permalink
add author
Browse files Browse the repository at this point in the history
  • Loading branch information
deepu105 committed Jun 10, 2024
1 parent 87fb4d3 commit 87e9da8
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions _source/_plugins/excerpt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,32 @@ 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_id = post['author']
author = context.registers[:site].data['authors'][author_id]
avatar = author['avatar']
display_name = author['full_name']
description = post['description']

if (description.nil?)
# Use excerpt in cases description doesn't exist. One day truncate text...
description = post['excerpt']
end

img=Liquid::Template.parse("{% img '#{avatar}' alt:'avatar-#{avatar}' class:BlogPost-avatar %}").render(context)

%(<article class="link-container" style="border: 1px solid silver; border-radius: 3px; padding: 12px 15px">
<a href='#{@article_id}' style="font-size: 1.375em; margin-bottom: 20px;">
<span>#{title}</span>
</a>
<p>#{description}</p>
<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>
</article>)
else
%(<div class="link-container">
Expand Down

0 comments on commit 87e9da8

Please sign in to comment.