Vulcan/packages/nova-base-components/lib/posts/PostsPage.jsx

97 lines
1.9 KiB
React
Raw Normal View History

import { Components, registerComponent } from 'meteor/nova:lib';
import React from 'react';
import Posts from 'meteor/nova:posts';
import { withSingle } from 'meteor/nova:core';
2016-11-23 11:07:48 +09:00
import gql from 'graphql-tag';
2016-10-27 15:29:15 +09:00
const PostsPage = (props) => {
2016-11-23 11:07:48 +09:00
if (props.loading) {
2016-02-18 16:26:52 +09:00
return <div className="posts-page"><Components.Loading/></div>
2016-02-18 16:26:52 +09:00
} else {
2016-03-22 10:38:57 +09:00
2016-11-23 11:07:48 +09:00
const post = props.document;
const htmlBody = {__html: post.htmlBody};
2016-03-22 10:38:57 +09:00
return (
<div className="posts-page">
<Components.HeadTags url={Posts.getLink(post)} title={post.title} image={post.thumbnailUrl} />
<Components.PostsItem post={post} />
2016-02-18 16:26:52 +09:00
{post.htmlBody ? <div className="posts-page-body" dangerouslySetInnerHTML={htmlBody}></div> : null}
2016-02-18 16:26:52 +09:00
{/*<SocialShare url={ Posts.getLink(post) } title={ post.title }/>*/}
<Components.PostsCommentsThread terms={{postId: post._id}} />
</div>
)
}
};
PostsPage.displayName = "PostsPage";
PostsPage.propTypes = {
document: React.PropTypes.object
}
2016-11-26 11:17:01 +09:00
PostsPage.fragment = gql`
fragment PostsSingleFragment on Post {
2016-11-23 11:07:48 +09:00
_id
title
url
body
htmlBody
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
}
userId
2016-11-23 11:07:48 +09:00
}
`;
const options = {
collection: Posts,
queryName: 'postsSingleQuery',
2016-11-26 11:17:01 +09:00
fragment: PostsPage.fragment,
};
registerComponent('PostsPage', PostsPage, withSingle(options));