App is using up-to-date meteor and Kadira FlowRouter with Blaze Layouts.
I copied this directly from the FlowRouter docs and changed their “adminSection” to my “blogDir” in my routes.js.
var blogDir = FlowRouter.group({
prefix: "/blog"
});
blogDir.route('/', {
action: function() {
console.log('here is a blog post');
}
});
When I go to http://localhost:3000/blog/my-great-post, there is no console message. Why?
This ALSO does not produce a console message at http://localhost:3000/blog/my-great-post. Why?
var blogDir = FlowRouter.group({
prefix: '/blog',
name: 'blog',
triggersEnter: [function(context, redirect) {
console.log('here is a blog post message from route group definition');
}]
});
It is not match the blogDir route.
your blogDir route path is /
so it match http://localhost:3000/blog/
but not http://localhost:3000/blog/my-great-post
.
Might be you can change your route to using param, ex /:post-title
. So it will match your url.
Read the docs please : https://github.com/kadirahq/flow-router
And because FlowRouter use path-to-regExp you should read the docs too : https://github.com/pillarjs/path-to-regexp
And test your route here : https://github.com/pillarjs/path-to-regexp
I will do that.
I did read the Kadira docs, but sometimes they are too brief. It seemed from their examples that to apply a function or action to a directory, it was only necessary to define the prefix, which I did.
Thank you for your reply!