|
@@ -8,7 +8,29 @@
|
|
|
*/
|
|
|
|
|
|
Router.configure({
|
|
|
- layoutTemplate: "layout"
|
|
|
+ layoutTemplate: "layout",
|
|
|
+ loadingTemplate: "loading",
|
|
|
+ notFoundTemplate: "notFound",
|
|
|
+ waitOn: function () {
|
|
|
+ return Meteor.subscribe('posts');
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
-Router.route('/', { name: 'postsList' });
|
|
|
+// C'est un nom de route, pas un nom de template. Mais IR le prend comme nom de template par défaut.
|
|
|
+Router.route('/', {
|
|
|
+ name: 'postsList'
|
|
|
+});
|
|
|
+
|
|
|
+Router.route('/posts/:_id', {
|
|
|
+ name: 'postPage',
|
|
|
+ data: function () {
|
|
|
+ // "this" is the matched route.
|
|
|
+ return Posts.findOne(this.params._id);
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+// Faire une 404 si la page matche la route postPage, mais pas son argument.
|
|
|
+// Déclenché pour toute valeur "falsy" (null, false, undefined, empty).
|
|
|
+Router.onBeforeAction('dataNotFound', {
|
|
|
+ only: 'postPage'
|
|
|
+});
|