@@ -52,32 +52,21 @@ export const PLUGINS = [
5252 category : 'Tooling' ,
5353 description : 'Lists every route as a page a crawler or a generator can read, and adds `router.sitemap()`.' ,
5454 } ,
55- {
56- name : 'dom' ,
57- short : 'String and element views, no framework' ,
58- category : 'Rendering' ,
59- description : 'Renders views as markup or elements into the page’s `<slot>`s, with no framework.' ,
60- } ,
6155] ;
6256
6357// the binding a plugin imports under: view-transitions → viewTransitions
6458export const bindingFor = ( name ) => name . replace ( / - ( \w ) / g, ( _ , c ) => c . toUpperCase ( ) ) ;
6559
66- // options a plugin needs to do anything, shown in the setup as the router's own: dom renders into a mount
67- const REQUIRED_OPTIONS = { dom : "mount: '#app'" } ;
68-
6960// the setup for a set of plugins, as nav-router's own examples write it: one import per plugin, for
70- // its effect, dom first, the renderer the others build on, and the plugins' options on the router
61+ // its effect, beside the router, which renders the dom without one
7162export function sampleFor ( names ) {
72- const picked = PLUGINS . map ( ( p ) => p . name ) . filter ( ( n ) => names . includes ( n ) )
73- . sort ( ( a , b ) => ( b === 'dom' ) - ( a === 'dom' ) ) ;
63+ const picked = PLUGINS . map ( ( p ) => p . name ) . filter ( ( n ) => names . includes ( n ) ) ;
7464 const lines = [ ] ;
7565 picked . forEach ( ( n ) => lines . push ( `import '@nav-router/plugins/${ n } ';` ) ) ;
7666 if ( ! picked . length ) { lines . push ( '// select plugins below to add them here' ) ; }
7767 lines . push ( "import { router } from 'nav-router';" , '' ) ;
78- const options = picked . map ( ( n ) => REQUIRED_OPTIONS [ n ] ) . filter ( Boolean ) ;
7968 lines . push ( 'const app = router({' ) ;
80- options . forEach ( ( option ) => lines . push ( ` ${ option } ,` ) ) ;
69+ lines . push ( " mount: '#app'," ) ;
8170 lines . push ( ' // the routes' , '});' ) ;
8271 return lines . join ( '\n' ) ;
8372}
0 commit comments