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

45 lines
1.1 KiB
React
Raw Normal View History

2017-01-23 10:30:58 +09:00
import { Components, registerComponent, withDocument, withCurrentUser } from 'meteor/nova:core';
import React from 'react';
import Posts from 'meteor/nova:posts';
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} description={post.excerpt} />
2017-01-23 10:30:58 +09:00
<Components.PostsItem post={post} currentUser={props.currentUser} />
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
<Components.PostsCommentsThread terms={{postId: post._id}} />
</div>
)
}
};
PostsPage.displayName = "PostsPage";
PostsPage.propTypes = {
document: React.PropTypes.object
}
const options = {
collection: Posts,
queryName: 'postsSingleQuery',
fragmentName: 'PostsPage',
};
registerComponent('PostsPage', PostsPage, withCurrentUser, [withDocument, options]);