Skip to content

Commit aab30d7

Browse files
committed
chore: allow extending PostPreview content
1 parent de36551 commit aab30d7

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

framework/core/js/src/forum/components/PostPreview.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,28 @@ export default class PostPreview extends Component {
1717
view() {
1818
const post = this.attrs.post;
1919
const user = post.user();
20-
const content = post.contentType() === 'comment' && post.contentPlain();
21-
const excerpt = content ? highlight(content, this.attrs.highlight, 300) : '';
2220

2321
return (
2422
<Link className="PostPreview" href={app.route.post(post)} onclick={this.attrs.onclick}>
2523
<span className="PostPreview-content">
2624
{avatar(user)}
27-
{username(user)} <span className="PostPreview-excerpt">{excerpt}</span>
25+
{username(user)} <span className="PostPreview-excerpt">{this.excerpt()}</span>
2826
</span>
2927
</Link>
3028
);
3129
}
30+
31+
/**
32+
* @returns {string|undefined|null}
33+
*/
34+
content() {
35+
return this.attrs.post.contentType() === 'comment' && this.attrs.post.contentPlain();
36+
}
37+
38+
/**
39+
* @returns {string}
40+
*/
41+
excerpt() {
42+
return this.content() ? highlight(this.content(), this.attrs.highlight, 300) : '';
43+
}
3244
}

0 commit comments

Comments
 (0)