Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fall back to 'Untitled' when no title is present
  • Loading branch information
danielbachhuber authored and westonruter committed Aug 3, 2017
commit 16b8160a144696454a749a7589e39eada188af6e
2 changes: 1 addition & 1 deletion blocks/library/latest-comments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ registerBlockType( 'core/latest-comments', {
{ displayAvatar && comment.author_avatar_urls[ 96 ] &&
<img className={ `${ this.props.className }__comment-avatar` } alt={ comment.author_name } src={ comment.author_avatar_urls[ 96 ] } />
}
<a href={ comment.link } target="_blank">{ comment._embedded.up[ 0 ].title.rendered }</a>
<a href={ comment.link } target="_blank">{ comment._embedded.up[ 0 ].title.rendered.trim() || __( '(Untitled)' ) }</a>
{ displayTimestamp && comment.date_gmt &&
<span className={ `${ this.props.className }__comment-timestamp` }>
{ moment( comment.date_gmt ).local().format( 'MMM DD h:mm A' ) }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This timestamp format seems like it should be user-configurable. Maybe we need a JS implementation of human_time_diff() with a filterable format.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moment.js does support relative time: https://momentjs.com/docs/#/displaying/fromnow/

It could be a nice block attribute to decide whether the dates are shown in relative time or absolute time, according to the site's datetime format.

See also #1992 (comment) and #1992 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to the site's datetime format.

Should we get a new issue going about respecting the site's datetime format?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it affects latest posts as well.

Expand Down