2017-01-23 10:30:58 +09:00
|
|
|
import { Components, registerComponent, withDocument, withCurrentUser } from 'meteor/nova:core';
|
2016-03-30 09:24:52 +09:00
|
|
|
import React from 'react';
|
2016-11-11 16:42:19 +09:00
|
|
|
import Posts from 'meteor/nova:posts';
|
2016-11-23 11:07:48 +09:00
|
|
|
import gql from 'graphql-tag';
|
2016-04-03 11:42:07 +09:00
|
|
|
|
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
|
|
|
|
2016-12-06 18:06:29 +01:00
|
|
|
return <div className="posts-page"><Components.Loading/></div>
|
2016-02-18 16:26:52 +09:00
|
|
|
|
2016-11-11 16:42:19 +09:00
|
|
|
} else {
|
2016-03-22 10:38:57 +09:00
|
|
|
|
2016-11-23 11:07:48 +09:00
|
|
|
const post = props.document;
|
|
|
|
|
2016-11-11 16:42:19 +09:00
|
|
|
const htmlBody = {__html: post.htmlBody};
|
2016-03-22 10:38:57 +09:00
|
|
|
|
2016-11-11 16:42:19 +09:00
|
|
|
return (
|
|
|
|
<div className="posts-page">
|
2016-12-06 18:06:29 +01:00
|
|
|
<Components.HeadTags url={Posts.getLink(post)} title={post.title} image={post.thumbnailUrl} />
|
2016-11-11 16:42:19 +09:00
|
|
|
|
2017-01-23 10:30:58 +09:00
|
|
|
<Components.PostsItem post={post} currentUser={props.currentUser} />
|
2016-02-18 16:26:52 +09:00
|
|
|
|
2016-11-11 16:42:19 +09:00
|
|
|
{post.htmlBody ? <div className="posts-page-body" dangerouslySetInnerHTML={htmlBody}></div> : null}
|
2016-02-18 16:26:52 +09:00
|
|
|
|
2016-11-11 16:42:19 +09:00
|
|
|
{/*<SocialShare url={ Posts.getLink(post) } title={ post.title }/>*/}
|
|
|
|
|
2016-12-06 18:06:29 +01:00
|
|
|
<Components.PostsCommentsThread terms={{postId: post._id}} />
|
2016-11-11 16:42:19 +09:00
|
|
|
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2016-04-02 15:03:55 +02:00
|
|
|
};
|
2016-02-15 22:33:44 +09:00
|
|
|
|
2016-05-22 16:42:24 +09:00
|
|
|
PostsPage.displayName = "PostsPage";
|
|
|
|
|
2016-11-03 14:07:58 +09:00
|
|
|
PostsPage.propTypes = {
|
2016-11-07 16:33:52 +01:00
|
|
|
document: React.PropTypes.object
|
2016-11-03 14:07:58 +09:00
|
|
|
}
|
|
|
|
|
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
|
2016-12-18 19:04:11 +09:00
|
|
|
body # extra
|
|
|
|
htmlBody # extra
|
2016-11-23 11:07:48 +09:00
|
|
|
slug
|
|
|
|
thumbnailUrl
|
|
|
|
baseScore
|
|
|
|
postedAt
|
|
|
|
sticky
|
|
|
|
status
|
|
|
|
categories {
|
|
|
|
# ...minimumCategoryInfo
|
|
|
|
_id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
}
|
|
|
|
commentCount
|
|
|
|
commenters {
|
|
|
|
# ...avatarUserInfo
|
|
|
|
_id
|
2017-01-18 10:18:33 +09:00
|
|
|
displayName
|
|
|
|
emailHash
|
|
|
|
slug
|
2016-11-23 11:07:48 +09:00
|
|
|
}
|
|
|
|
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
|
2017-01-18 10:18:33 +09:00
|
|
|
displayName
|
|
|
|
emailHash
|
|
|
|
slug
|
2016-11-23 11:07:48 +09:00
|
|
|
}
|
2016-11-30 16:54:58 +09:00
|
|
|
userId
|
2016-11-23 11:07:48 +09:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2016-11-22 18:14:51 -05:00
|
|
|
const options = {
|
|
|
|
collection: Posts,
|
|
|
|
queryName: 'postsSingleQuery',
|
2016-11-26 11:17:01 +09:00
|
|
|
fragment: PostsPage.fragment,
|
2016-11-22 18:14:51 -05:00
|
|
|
};
|
|
|
|
|
2017-01-23 10:30:58 +09:00
|
|
|
registerComponent('PostsPage', PostsPage, withCurrentUser, withDocument(options));
|