diff --git a/framework/core/js/src/forum/components/PostPreview.js b/framework/core/js/src/forum/components/PostPreview.js index 5293bd3c17..6f200c7c4c 100644 --- a/framework/core/js/src/forum/components/PostPreview.js +++ b/framework/core/js/src/forum/components/PostPreview.js @@ -17,16 +17,28 @@ export default class PostPreview extends Component { view() { const post = this.attrs.post; const user = post.user(); - const content = post.contentType() === 'comment' && post.contentPlain(); - const excerpt = content ? highlight(content, this.attrs.highlight, 300) : ''; return ( {avatar(user)} - {username(user)} {excerpt} + {username(user)} {this.excerpt()} ); } + + /** + * @returns {string|undefined|null} + */ + content() { + return this.attrs.post.contentType() === 'comment' && this.attrs.post.contentPlain(); + } + + /** + * @returns {string} + */ + excerpt() { + return this.content() ? highlight(this.content(), this.attrs.highlight, 300) : ''; + } }