2017-08-11 03:13:36 +09:00
|
|
|
import * as riot from 'riot';
|
2017-11-13 18:05:35 +09:00
|
|
|
import * as route from 'page';
|
2017-02-18 18:03:52 +09:00
|
|
|
let page = null;
|
|
|
|
|
2017-11-16 03:06:52 +09:00
|
|
|
export default () => {
|
2017-02-18 18:03:52 +09:00
|
|
|
route('/', index);
|
|
|
|
route('/apps', apps);
|
|
|
|
route('/app/new', newApp);
|
|
|
|
route('/app/:app', app);
|
|
|
|
route('*', notFound);
|
|
|
|
|
|
|
|
function index() {
|
|
|
|
mount(document.createElement('mk-index'));
|
|
|
|
}
|
|
|
|
|
|
|
|
function apps() {
|
|
|
|
mount(document.createElement('mk-apps-page'));
|
|
|
|
}
|
|
|
|
|
|
|
|
function newApp() {
|
|
|
|
mount(document.createElement('mk-new-app-page'));
|
|
|
|
}
|
|
|
|
|
|
|
|
function app(ctx) {
|
|
|
|
const el = document.createElement('mk-app-page');
|
|
|
|
el.setAttribute('app', ctx.params.app);
|
|
|
|
mount(el);
|
|
|
|
}
|
|
|
|
|
|
|
|
function notFound() {
|
|
|
|
mount(document.createElement('mk-not-found'));
|
|
|
|
}
|
|
|
|
|
|
|
|
// EXEC
|
2017-11-13 18:05:35 +09:00
|
|
|
(route as any)();
|
2017-02-18 18:03:52 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
function mount(content) {
|
|
|
|
if (page) page.unmount();
|
|
|
|
const body = document.getElementById('app');
|
|
|
|
page = riot.mount(body.appendChild(content))[0];
|
|
|
|
}
|