import { Components, getRawComponent, replaceComponent } from 'meteor/nova:lib'; import React, { PropTypes, Component } from 'react'; import { FormattedMessage, FormattedRelative } from 'react-intl'; import { Button } from 'react-bootstrap'; import moment from 'moment'; import { ModalTrigger } from "meteor/nova:core"; import { Link } from 'react-router'; import Posts from "meteor/nova:posts"; import Categories from "meteor/nova:categories"; import gql from 'graphql-tag'; class CustomPostsItem extends getRawComponent('PostsItem') { render() { const post = this.props.post; let postClass = "posts-item"; if (post.sticky) postClass += " posts-sticky"; // ⭐ custom code starts here ⭐ if (post.color) { postClass += " post-"+post.color; } // ⭐ custom code ends here ⭐ return (
{post.thumbnailUrl ? : null}

{post.title} {this.renderCategories()}

{post.user?
: null}
{this.props.currentUser && this.props.currentUser.isAdmin ? : null} {this.renderActions()}
{this.renderCommenters()}
) } }; CustomPostsItem.propTypes = { currentUser: React.PropTypes.object, post: React.PropTypes.object.isRequired }; CustomPostsItem.fragment = gql` fragment PostsItemFragment on Post { _id title url slug thumbnailUrl baseScore postedAt sticky status categories { # ...minimumCategoryInfo _id name slug } commentCount commenters { # ...avatarUserInfo _id __displayName __emailHash __slug } upvoters { _id } downvoters { _id } upvotes # should be asked only for admins? score # should be asked only for admins? viewCount # should be asked only for admins? clickCount # should be asked only for admins? user { # ...avatarUserInfo _id __displayName __emailHash __slug } color } `; replaceComponent('PostsItem', CustomPostsItem);