2016-04-22 10:46:09 +09:00
|
|
|
import React from 'react';
|
|
|
|
import {mount} from 'react-mounter';
|
2016-06-19 15:17:44 +09:00
|
|
|
import { Messages } from 'meteor/nova:core';
|
2016-06-12 12:11:05 +09:00
|
|
|
import { IndexRoute, Route, useRouterHistory, browserHistory, createMemoryHistory } from 'react-router';
|
2016-06-10 19:19:32 +09:00
|
|
|
import { ReactRouterSSR } from 'meteor/reactrouter:react-router-ssr';
|
2016-06-06 10:06:53 +09:00
|
|
|
import { ListContainer, DocumentContainer } from "meteor/utilities:react-list-container";
|
2016-06-21 18:07:47 +09:00
|
|
|
// import useNamedRoutes from 'use-named-routes';
|
2016-06-12 12:11:05 +09:00
|
|
|
import createBrowserHistory from 'history/lib/createBrowserHistory';
|
2016-06-23 15:16:32 +09:00
|
|
|
import Events from "meteor/nova:events";
|
2016-06-29 09:15:52 +02:00
|
|
|
import Helmet from 'react-helmet';
|
2016-06-10 19:19:32 +09:00
|
|
|
|
|
|
|
// // ------------------------------------- Other -------------------------------- //
|
|
|
|
|
|
|
|
// FlowRouter.notFound = {
|
|
|
|
// action() {
|
|
|
|
// ({App, Error404} = Telescope.components);
|
|
|
|
// mount(App, {content: <Error404/>});
|
|
|
|
// }
|
|
|
|
// };
|
|
|
|
|
2016-06-15 11:07:30 +09:00
|
|
|
Meteor.startup(() => {
|
2016-06-11 16:36:18 +09:00
|
|
|
|
2016-06-15 11:07:30 +09:00
|
|
|
Telescope.routes.add([
|
|
|
|
{name:"posts.daily", path:"daily", component:Telescope.components.PostsDaily},
|
|
|
|
{name:"posts.single", path:"posts/:_id(/:slug)", component:Telescope.components.PostsSingle},
|
|
|
|
{name:"users.single", path:"users/:slug", component:Telescope.components.UsersSingle},
|
|
|
|
{name:"users.account", path:"account", component:Telescope.components.UsersAccount},
|
|
|
|
{name:"users.edit", path:"users/:slug/edit", component:Telescope.components.UsersAccount}
|
|
|
|
]);
|
2016-06-13 16:02:27 +09:00
|
|
|
|
2016-06-15 11:07:30 +09:00
|
|
|
const AppRoutes = {
|
|
|
|
path: '/',
|
|
|
|
component: Telescope.components.App,
|
|
|
|
indexRoute: { name: "posts.list", component: Telescope.components.PostsHome },
|
|
|
|
childRoutes: Telescope.routes.routes
|
|
|
|
}
|
2016-06-14 10:01:44 +09:00
|
|
|
|
2016-06-15 11:07:30 +09:00
|
|
|
let history;
|
2016-06-12 12:11:05 +09:00
|
|
|
|
2016-06-15 11:07:30 +09:00
|
|
|
const clientOptions = {}, serverOptions = {};
|
2016-06-12 12:11:05 +09:00
|
|
|
|
2016-06-21 18:07:47 +09:00
|
|
|
// if (Meteor.isClient) {
|
|
|
|
// history = useNamedRoutes(useRouterHistory(createBrowserHistory))({ routes: AppRoutes });
|
|
|
|
// }
|
2016-06-14 10:01:44 +09:00
|
|
|
|
2016-06-21 18:07:47 +09:00
|
|
|
// if (Meteor.isServer) {
|
|
|
|
// history = useNamedRoutes(useRouterHistory(createMemoryHistory))({ routes: AppRoutes });
|
|
|
|
// }
|
2016-06-15 11:07:30 +09:00
|
|
|
|
2016-06-19 15:17:44 +09:00
|
|
|
clientOptions.props = {onUpdate: () => {Events.analyticsRequest(); Messages.clearSeen();}};
|
2016-06-15 11:07:30 +09:00
|
|
|
|
2016-06-29 09:15:52 +02:00
|
|
|
serverOptions.htmlHook = (html) => {
|
|
|
|
const head = Helmet.rewind();
|
|
|
|
return html.replace('<head>', '<head>'+ head.title + head.meta + head.link);
|
|
|
|
}
|
|
|
|
|
2016-06-15 11:07:30 +09:00
|
|
|
// ReactRouterSSR.Run(AppRoutes, {historyHook: () => history}, {historyHook: () => history});
|
|
|
|
ReactRouterSSR.Run(AppRoutes, clientOptions, serverOptions);
|
|
|
|
|
|
|
|
});
|