Closed neetjn closed 4 years ago
See: core-routing for router interface. Once version 0.0.1 is feature completed and tested, I'll begin drafting a road map for riot-routing.
Update (9/2/19):
<Root>
<script>
import {Home} from './containers/home.riot';
import {NotFound} from './containers/notFound.riot';
</script>
<Router default="/">
<Route path="/" component={Home} />
<Route path="*" component={ NotFound } />
</Router>
<Link to="/">Home</Link>
Update (9/11/19):
Update (9/27/19):
component
function in the router component.Update (9/28/19):
root.riot
<Root>
<router routes={ routes } />
<script>
import Router from 'riot-routing/router.riot'
import Home from './components/home.riot'
import NotFound from './component/not-found.riot'
const routes = [
{ component: Home, path: ['/', '/home'] },
{ component: NotFound, path: '*' }
]
export default {
routes,
components: {
Router
}
}
</script>
</Root>
router.riot
<Router>
<route each={ route in props.routes } if={ route.active } />
</Router>
route.riot
TBD
After thoughtful consideration, I've decided to drop the [riot-view-router]() project and start from scratch. Riot.js 4 is a complete overhaul of the framework, with a fundamentally different api. My initial observations can be read here.
Roadmap - 0.0.1
Router
component for instantiating a new core-routing instance, this component should provide a client to subscribe to routing mechanisms. Router should adjust current base path depending on thedefault
prop if current location is not recognized.Route
component for defining a route. This component will expect two props,path
andcomponent
. Thepath
prop specifies the target route, it will support argument interpolation in the form/route/:arg1/path
or in practice/user/:userId/profile
.Link
component for declaratively creating an anchor.