The route table
From here on you are building Music itself. It starts small: a shop page that lists eight albums, and a playlist page that nothing points to yet.
routes.js exports the route table, an array with one entry per page. Each route has a path to match, a name to refer to it by, and the view to render there. The router reads the table top to bottom and renders the first route whose path matches the URL.
Your turn
- Type
/playlistinto the preview's address bar and press Enter. The console says no route matches it. - In
routes.js, import the view:import PlaylistView from './views/Playlist.pzl'; - Add a route for it:
{ path: '/playlist', name: 'playlist', view: PlaylistView }. - Try
/playlistagain.
The preview runs your app with an in-memory router, so its address bar is separate from this page's. In your own app the router reads and writes the real URL.