mirror of
https://github.com/flarum/core.git
synced 2025-08-07 17:07:19 +02:00
chore: allow extending PostPreview content (#4043)
This commit is contained in:
@@ -17,16 +17,28 @@ export default class PostPreview extends Component {
|
|||||||
view() {
|
view() {
|
||||||
const post = this.attrs.post;
|
const post = this.attrs.post;
|
||||||
const user = post.user();
|
const user = post.user();
|
||||||
const content = post.contentType() === 'comment' && post.contentPlain();
|
|
||||||
const excerpt = content ? highlight(content, this.attrs.highlight, 300) : '';
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link className="PostPreview" href={app.route.post(post)} onclick={this.attrs.onclick}>
|
<Link className="PostPreview" href={app.route.post(post)} onclick={this.attrs.onclick}>
|
||||||
<span className="PostPreview-content">
|
<span className="PostPreview-content">
|
||||||
{avatar(user)}
|
{avatar(user)}
|
||||||
{username(user)} <span className="PostPreview-excerpt">{excerpt}</span>
|
{username(user)} <span className="PostPreview-excerpt">{this.excerpt()}</span>
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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) : '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user