mirror of
https://github.com/vale981/Vulcan
synced 2025-03-05 17:41:43 -05:00
make customizing index route easier; update readme
This commit is contained in:
parent
1d1a556fb8
commit
739de3254c
2 changed files with 34 additions and 11 deletions
33
README.md
33
README.md
|
@ -475,7 +475,9 @@ You can use regular Meteor methods, or [Smart Methods](https://github.com/meteor
|
||||||
|
|
||||||
## Routes
|
## Routes
|
||||||
|
|
||||||
Here's how you can add routes to your app (using React Router):
|
### Customizing Routes
|
||||||
|
|
||||||
|
Here's how you can add child routes to your app (using React Router):
|
||||||
|
|
||||||
```js
|
```js
|
||||||
Telescope.routes.add({
|
Telescope.routes.add({
|
||||||
|
@ -485,6 +487,35 @@ Telescope.routes.add({
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To change the index (`/`) route, you can do:
|
||||||
|
|
||||||
|
```js
|
||||||
|
Telescope.routes.indexRoute = {
|
||||||
|
name: "myIndexRoute",
|
||||||
|
component: myIndexRouteComponent
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
For more complex router customizations, you can also disable the `nova:base-routes` package altogether and replace it with your own React Router code.
|
||||||
|
|
||||||
|
### Using React Router In Your Components
|
||||||
|
|
||||||
|
If you need to access router properties (such as the current route, path, or query parameters) inside a component, you'll need to wrap that component with the `withRouter` HoC (higher-order component):
|
||||||
|
|
||||||
|
```js
|
||||||
|
import React, { PropTypes, Component } from 'react';
|
||||||
|
import { withRouter } from 'react-router'
|
||||||
|
|
||||||
|
class SearchForm extends Component{
|
||||||
|
|
||||||
|
render() {
|
||||||
|
// this.props.router is accessible
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withRouter(SearchForm);
|
||||||
|
```
|
||||||
|
|
||||||
## Groups & Permissions
|
## Groups & Permissions
|
||||||
|
|
||||||
User groups let you give your users permission to perform specific actions.
|
User groups let you give your users permission to perform specific actions.
|
||||||
|
|
|
@ -9,19 +9,11 @@ import createBrowserHistory from 'history/lib/createBrowserHistory';
|
||||||
import Events from "meteor/nova:events";
|
import Events from "meteor/nova:events";
|
||||||
import Helmet from 'react-helmet';
|
import Helmet from 'react-helmet';
|
||||||
|
|
||||||
// // ------------------------------------- Other -------------------------------- //
|
Telescope.routes.indexRoute = { name: "posts.list", component: Telescope.components.PostsHome };
|
||||||
|
|
||||||
// FlowRouter.notFound = {
|
|
||||||
// action() {
|
|
||||||
// ({App, Error404} = Telescope.components);
|
|
||||||
// mount(App, {content: <Error404/>});
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
Meteor.startup(() => {
|
Meteor.startup(() => {
|
||||||
|
|
||||||
Telescope.routes.add([
|
Telescope.routes.add([
|
||||||
{name:"posts.daily", path:"daily", component:Telescope.components.PostsDaily},
|
|
||||||
{name:"posts.single", path:"posts/:_id(/:slug)", component:Telescope.components.PostsSingle},
|
{name:"posts.single", path:"posts/:_id(/:slug)", component:Telescope.components.PostsSingle},
|
||||||
{name:"users.single", path:"users/:slug", component:Telescope.components.UsersSingle},
|
{name:"users.single", path:"users/:slug", component:Telescope.components.UsersSingle},
|
||||||
{name:"users.account", path:"account", component:Telescope.components.UsersAccount},
|
{name:"users.account", path:"account", component:Telescope.components.UsersAccount},
|
||||||
|
@ -31,7 +23,7 @@ Meteor.startup(() => {
|
||||||
const AppRoutes = {
|
const AppRoutes = {
|
||||||
path: '/',
|
path: '/',
|
||||||
component: Telescope.components.App,
|
component: Telescope.components.App,
|
||||||
indexRoute: { name: "posts.list", component: Telescope.components.PostsHome },
|
indexRoute: Telescope.routes.indexRoute,
|
||||||
childRoutes: Telescope.routes.routes
|
childRoutes: Telescope.routes.routes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue