Howdy howdy howdy,
I’m trying to include a link to a dynamic route in a post, referencing it via ‘pathFor’, but when the page is rendered the carries no ‘href’. Here’s my code:
Router:
Router.route("/category/:category", function() {
this.render("categoryList", {
waitOn: function() {
return Meteor.subscribe("posts");
},
data: function() {
console.log('category data function running!');
return {
category: Posts.find({category: this.params.category})
}
}
});
}, {
name: 'categoryList'
});
Template:
<a href="{{ pathFor 'categoryList' }}">{{post.category}}</a></p>
Also, possibly relevant, this Router for a ‘post’:
Router.route("/:permalink", function(){
this.render("post", {
waitOn: function() {
return [
Meteor.subscribe("posts", this.params.permalink),
Meteor.subscribe("postComments", this.params.permalink)
]
},
data: function() {
thisPost = Posts.findOne({permalink: this.params.permalink});
cpId = thisPost ? thisPost._id : null;
Session.set("currentPostId", cpId);
console.log('post function running!');
return {
post: thisPost,
comments: thisPost ? Comments.find({postId: thisPost._id, commentStatus: 'published'}) : null
}
}
});
}, {
name: 'post'
});
You’ll notice I’m having to use a ternary operator in the post’s data function for the comments object. No clue why, but I get an error if I don’t.
Would appreciate someone more experienced taking a look. Thanks!