mirror of
https://github.com/flarum/framework.git
synced 2025-05-28 19:06:35 +08:00
New component for post excerpts, which will be shown in search results
Perhaps also in user activity stream. They are used in the mentions extension. In order to generate the excerpt, each formatter can implement a “strip” method which basically converts block formatting into inline formatting.
This commit is contained in:
22
js/forum/src/components/post-preview.js
Normal file
22
js/forum/src/components/post-preview.js
Normal file
@ -0,0 +1,22 @@
|
||||
import Component from 'flarum/component';
|
||||
import avatar from 'flarum/helpers/avatar';
|
||||
import username from 'flarum/helpers/username';
|
||||
import humanTime from 'flarum/helpers/human-time';
|
||||
|
||||
export default class PostPreview extends Component {
|
||||
view() {
|
||||
var post = this.props.post;
|
||||
var user = post.user();
|
||||
|
||||
return m('a.post-preview', {
|
||||
href: app.route.post(post),
|
||||
config: m.route,
|
||||
onclick: this.props.onclick
|
||||
}, m('div.post-preview-content', [
|
||||
avatar(user), ' ',
|
||||
username(user), ' ',
|
||||
humanTime(post.time()), ' ',
|
||||
post.excerpt()
|
||||
]));
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ Post.prototype.user = Model.one('user');
|
||||
Post.prototype.contentType = Model.prop('contentType');
|
||||
Post.prototype.content = Model.prop('content');
|
||||
Post.prototype.contentHtml = Model.prop('contentHtml');
|
||||
Post.prototype.excerpt = Model.prop('excerpt');
|
||||
|
||||
Post.prototype.editTime = Model.prop('editTime', Model.date);
|
||||
Post.prototype.editUser = Model.one('editUser');
|
||||
|
Reference in New Issue
Block a user