mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 04:26:41 -04:00
96 lines
1.9 KiB
JavaScript
96 lines
1.9 KiB
JavaScript
import { Components, registerComponent } from 'meteor/nova:lib';
|
|
import React from 'react';
|
|
import Posts from 'meteor/nova:posts';
|
|
import { withDocument } from 'meteor/nova:core';
|
|
import gql from 'graphql-tag';
|
|
|
|
const PostsPage = (props) => {
|
|
|
|
if (props.loading) {
|
|
|
|
return <div className="posts-page"><Components.Loading/></div>
|
|
|
|
} else {
|
|
|
|
const post = props.document;
|
|
|
|
const htmlBody = {__html: post.htmlBody};
|
|
|
|
return (
|
|
<div className="posts-page">
|
|
<Components.HeadTags url={Posts.getLink(post)} title={post.title} image={post.thumbnailUrl} />
|
|
|
|
<Components.PostsItem post={post} />
|
|
|
|
{post.htmlBody ? <div className="posts-page-body" dangerouslySetInnerHTML={htmlBody}></div> : null}
|
|
|
|
{/*<SocialShare url={ Posts.getLink(post) } title={ post.title }/>*/}
|
|
|
|
<Components.PostsCommentsThread terms={{postId: post._id}} />
|
|
|
|
</div>
|
|
)
|
|
}
|
|
};
|
|
|
|
PostsPage.displayName = "PostsPage";
|
|
|
|
PostsPage.propTypes = {
|
|
document: React.PropTypes.object
|
|
}
|
|
|
|
PostsPage.fragment = gql`
|
|
fragment PostsSingleFragment on Post {
|
|
_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
|
|
}
|
|
`;
|
|
|
|
const options = {
|
|
collection: Posts,
|
|
queryName: 'postsSingleQuery',
|
|
fragment: PostsPage.fragment,
|
|
};
|
|
|
|
registerComponent('PostsPage', PostsPage, withDocument(options));
|