Skip to content

Commit

Permalink
[LatestPosts] Don't trim manual excerpts (#20432)
Browse files Browse the repository at this point in the history
* adds raw excerpt to the LatestPosts block and respects manual excerpts

* removed the reset to raw excerpt
  • Loading branch information
draganescu authored and jorgefilipecosta committed Mar 10, 2020
1 parent d965f07 commit 5b68c74
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions packages/block-library/src/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,21 @@ class LatestPostsEdit extends Component {
[ `align${ featuredImageAlign }` ]: !! featuredImageAlign,
} );

const postExcerpt =
excerptLength <
excerpt.trim().split( ' ' ).length &&
post.excerpt.raw === ''
? excerpt
.trim()
.split( ' ', excerptLength )
.join( ' ' ) +
' ... <a href=' +
post.link +
'target="_blank" rel="noopener noreferrer">' +
__( 'Read more' ) +
'</a>'
: excerpt;

return (
<li key={ i }>
{ displayFeaturedImage && (
Expand Down Expand Up @@ -372,28 +387,7 @@ class LatestPostsEdit extends Component {
displayPostContentRadio === 'excerpt' && (
<div className="wp-block-latest-posts__post-excerpt">
<RawHTML key="html">
{ excerptLength <
excerpt.trim().split( ' ' )
.length
? excerpt
.trim()
.split(
' ',
excerptLength
)
.join( ' ' ) +
' ... <a href=' +
post.link +
'target="_blank" rel="noopener noreferrer">' +
__( 'Read more' ) +
'</a>'
: excerpt
.trim()
.split(
' ',
excerptLength
)
.join( ' ' ) }
{ postExcerpt }
</RawHTML>
</div>
) }
Expand Down

0 comments on commit 5b68c74

Please sign in to comment.