Skip to content
Snippets Groups Projects
Commit 6cd3c3e9 authored by syuilo's avatar syuilo
Browse files

✌️

parent 201f48d7
No related branches found
No related tags found
No related merge requests found
const route = require('page');
let page = null;
module.exports = me => {
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
route();
};
const riot = require('riot');
function mount(content) {
if (page) page.unmount();
const body = document.getElementById('app');
page = riot.mount(body.appendChild(content))[0];
}
# Router
#================================
route = require \page
page = null
module.exports = (me) ~>
# Routing
#--------------------------------
route \/ index
route \/apps apps
route \/app/new new-app
route \/app/:app app
route \* not-found
# Handlers
#--------------------------------
function index
mount document.create-element \mk-index
function apps
mount document.create-element \mk-apps-page
function new-app
mount document.create-element \mk-new-app-page
function app ctx
document.create-element \mk-app-page
..set-attribute \app ctx.params.app
.. |> mount
function not-found
mount document.create-element \mk-not-found
# Exec
#--------------------------------
route!
# Mount
#================================
riot = require \riot
function mount content
if page? then page.unmount!
body = document.get-element-by-id \app
page := riot.mount body.append-child content .0
......@@ -3,8 +3,8 @@
*/
require('./tags');
const boot = require('../boot.js');
const route = require('./router.ls');
const boot = require('../boot');
const route = require('./router');
/**
* Boot
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment