-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: byline, avatar and date in carousel block (#455)
* fix: byline, avatar and date in carousel block * feat: real author links for avatar and author name
- Loading branch information
Jefferson Rabb
authored
May 5, 2020
1 parent
94c0a2b
commit 85b7865
Showing
4 changed files
with
57 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { _x } from '@wordpress/i18n'; | ||
import { RawHTML } from '@wordpress/element'; | ||
|
||
export const formatAvatars = authorInfo => | ||
authorInfo.map( author => ( | ||
<span className="avatar author-avatar" key={ author.id }> | ||
<a className="url fn n" href={ author.author_link }> | ||
<RawHTML>{ author.avatar }</RawHTML> | ||
</a> | ||
</span> | ||
) ); | ||
|
||
export const formatByline = authorInfo => ( | ||
<span className="byline"> | ||
{ _x( 'by', 'post author', 'newspack-blocks' ) }{' '} | ||
{ authorInfo.reduce( ( accumulator, author, index ) => { | ||
return [ | ||
...accumulator, | ||
<span className="author vcard" key={ author.id }> | ||
<a className="url fn n" href={ author.author_link }> | ||
{ author.display_name } | ||
</a> | ||
</span>, | ||
index < authorInfo.length - 2 && ', ', | ||
authorInfo.length > 1 && | ||
index === authorInfo.length - 2 && | ||
_x( ' and ', 'post author', 'newspack-blocks' ), | ||
]; | ||
}, [] ) } | ||
</span> | ||
); |