-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrouter.jsx
102 lines (90 loc) · 2.34 KB
/
router.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// We need to scroll to the top automatically for
// route change. That feels nice
FlowRouter.triggers.enter([Triggers.jumpToPrevScrollPosition]);
FlowRouter.triggers.exit([Triggers.saveScrollPosition]);
FlowRouter.triggers.enter([Triggers.sendPageToGa]);
['/', '/mup'].forEach(function(path) {
FlowRouter.route(path, {
name: "home",
action() {
var props = {
testimonials: TestimonialsData,
features: FeaturesData
};
ReactLayout.render(MainLayout, {
main: <Components.Home {...props}/>
});
}
});
});
FlowRouter.route('/pricing', {
action() {
ReactLayout.render(MainLayout, {main: <Components.Pricing />});
}
});
FlowRouter.route('/platform/:setName?/:page?/:subNav?', {
name: 'platform',
action() {
var props = {
category: 'platform',
titlePostfix: 'Kadira Platform',
showOnlyFirstPage: true
};
ReactLayout.render(MainLayout, {main: <Components.PageManager {...props}/>});
}
});
FlowRouter.route('/blog/:category?/:slug?', {
action(params) {
ReactLayout.render(MainLayout, {
main: <Components.Blog {...params}/>
});
}
});
FlowRouter.route('/academy', {
action() {
ReactLayout.render(MainLayout, {main: <Components.Academy />});
}
});
FlowRouter.route('/genie', {
name: "genie",
action() {
ReactLayout.render(MainLayout, {main: <Components.Genie />});
}
});
FlowRouter.route('/academy/:courseName/:setName?/:page?/:subNav?', {
name: 'academy-courses',
action(params) {
var props = {
category: params.courseName,
titlePostfix: slugToText(params.courseName),
pathPrefix: "/academy"
};
ReactLayout.render(MainLayout, {main: <Components.PageManager {...props}/>});
}
});
FlowRouter.route('/academy/:slug?', {
action(params) {
ReactLayout.render(MainLayout, {
main: <Components.AcademyList {...params}/>
});
}
});
FlowRouter.route('/:slug', {
action(params) {
params.slug = params.slug.replace('.html', '');
ReactLayout.render(MainLayout, {
main: <Components.OtherPage {...params}/>
});
}
});
function scrollToTop() {
$("body").animate({scrollTop: 0}, 0);
}
function slugToText(slug) {
var text = slug.split('-').map(function(w) {
var firstChar = w.charAt(0).toUpperCase();
var rest = w.substring(1);
return firstChar + rest;
}).join(' ');
return text;
}