File tree 3 files changed +21
-10
lines changed
3 files changed +21
-10
lines changed Original file line number Diff line number Diff line change 1
- Template . postsList . helpers ( {
2
- posts : function ( ) {
3
- return Posts . find ( { } , { sort : { submitted : - 1 } } ) ;
4
- }
5
- } ) ;
Original file line number Diff line number Diff line change @@ -3,12 +3,10 @@ Router.configure({
3
3
loadingTemplate : 'loading' ,
4
4
notFoundTemplate : 'notFound' ,
5
5
waitOn : function ( ) {
6
- return [ Meteor . subscribe ( 'posts' ) , Meteor . subscribe ( ' notifications') ]
6
+ return [ Meteor . subscribe ( 'notifications' ) ]
7
7
}
8
8
} ) ;
9
9
10
- Router . route ( '/' , { name : 'postsList' } ) ;
11
-
12
10
Router . route ( '/posts/:_id' , {
13
11
name : 'postPage' ,
14
12
waitOn : function ( ) {
@@ -24,6 +22,20 @@ Router.route('/posts/:_id/edit', {
24
22
25
23
Router . route ( '/submit' , { name : 'postSubmit' } ) ;
26
24
25
+ Router . route ( '/:postsLimit?' , {
26
+ name : 'postsList' ,
27
+ waitOn : function ( ) {
28
+ var limit = parseInt ( this . params . postsLimit ) || 5 ;
29
+ return Meteor . subscribe ( 'posts' , { sort : { submitted : - 1 } , limit : limit } ) ;
30
+ } ,
31
+ data : function ( ) {
32
+ var limit = parseInt ( this . params . postsLimit ) || 5 ;
33
+ return {
34
+ posts : Posts . find ( { } , { sort : { submitted : - 1 } , limit : limit } )
35
+ } ;
36
+ }
37
+ } ) ;
38
+
27
39
var requireLogin = function ( ) {
28
40
if ( ! Meteor . user ( ) ) {
29
41
if ( Meteor . loggingIn ( ) ) {
Original file line number Diff line number Diff line change 1
- Meteor . publish ( 'posts' , function ( ) {
2
- return Posts . find ( ) ;
1
+ Meteor . publish ( 'posts' , function ( options ) {
2
+ check ( options , {
3
+ sort : Object ,
4
+ limit : Number
5
+ } ) ;
6
+ return Posts . find ( { } , options ) ;
3
7
} ) ;
4
8
5
9
Meteor . publish ( 'comments' , function ( postId ) {
You can’t perform that action at this time.
0 commit comments