2016-03-22 10:22:46 +09:00
|
|
|
import React, { PropTypes, Component } from 'react';
|
2016-06-06 10:06:53 +09:00
|
|
|
import { ListContainer } from "meteor/utilities:react-list-container";
|
2016-06-07 15:03:00 +09:00
|
|
|
import moment from 'moment';
|
2016-06-23 11:40:35 +09:00
|
|
|
import Posts from "meteor/nova:posts";
|
2016-03-30 10:52:40 +09:00
|
|
|
|
2016-04-25 17:02:41 +09:00
|
|
|
class PostsDay extends Component {
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
const {date, number} = this.props;
|
|
|
|
|
|
|
|
const terms = {
|
|
|
|
view: "top",
|
|
|
|
date: date,
|
|
|
|
after: moment(date).format("YYYY-MM-DD"),
|
|
|
|
before: moment(date).format("YYYY-MM-DD"),
|
2016-06-06 10:06:53 +09:00
|
|
|
enableCache: number <= 15 ? true : false, // only cache first 15 days
|
|
|
|
listId: `posts.list.${moment(date).format("YYYY-MM-DD")}`
|
2016-04-25 17:02:41 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
({selector, options} = Posts.parameters.get(terms));
|
|
|
|
|
2016-06-07 09:43:23 +09:00
|
|
|
const postsPerPage = Telescope.settings.get("postsPerPage", 10);
|
|
|
|
|
2016-04-25 17:02:41 +09:00
|
|
|
return (
|
|
|
|
<div className="posts-day">
|
|
|
|
<h4 className="posts-day-heading">{moment(date).format("dddd, MMMM Do YYYY")}</h4>
|
|
|
|
<ListContainer
|
|
|
|
collection={Posts}
|
|
|
|
publication="posts.list"
|
|
|
|
selector={selector}
|
|
|
|
options={options}
|
|
|
|
terms={terms}
|
|
|
|
joins={Posts.getJoins()}
|
2016-05-22 16:42:24 +09:00
|
|
|
component={Telescope.components.PostsList}
|
2016-04-25 17:02:41 +09:00
|
|
|
componentProps={{showHeader: false}}
|
2016-06-06 10:06:53 +09:00
|
|
|
listId={terms.listId}
|
2016-06-07 09:43:23 +09:00
|
|
|
limit={postsPerPage}
|
2016-04-25 17:02:41 +09:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-03-22 10:22:46 +09:00
|
|
|
}
|
|
|
|
|
2016-04-14 10:12:35 +09:00
|
|
|
PostsDay.propTypes = {
|
2016-03-22 10:22:46 +09:00
|
|
|
date: React.PropTypes.object,
|
|
|
|
number: React.PropTypes.number
|
|
|
|
}
|
|
|
|
|
2016-04-14 10:12:35 +09:00
|
|
|
module.exports = PostsDay;
|
|
|
|
export default PostsDay;
|