1+ import { frameworkOf , FRAMEWORKS } from './frameworks.js' ;
12import { PLUGINS } from './plugins.js' ;
23
34// the docs' order. an item points at a page by slug; a slug with no page yet is listed as a stub,
45// so the shape of the docs is visible before every page exists.
6+ //
7+ // a group with `framework` is that framework's slot: the sidebar shows it only while the reader has
8+ // picked that framework. its pages live under the framework's folder (guides/solid/…), so the same
9+ // page for another framework is found by swapping the folder.
10+
11+ // what changes from one view layer to the next: how views are written and how they read the route.
12+ // the shape is a sketch until the integrations settle
13+ const FRAMEWORK_GUIDES = {
14+ core : [ [ 'Views with the dom plugin' , 'dom-views' ] , [ 'Web components' , 'web-components' ] ] ,
15+ react : [ [ 'Quickstart' , 'quickstart' ] , [ 'Components and hooks' , 'components' ] , [
16+ 'Suspense and transitions' ,
17+ 'suspense' ,
18+ ] ] ,
19+ preact : [ [ 'Quickstart' , 'quickstart' ] , [ 'Components and hooks' , 'components' ] ] ,
20+ solid : [ [ 'Quickstart' , 'quickstart' ] , [ 'Views and props' , 'views' ] , [ 'Shared state' , 'state' ] ] ,
21+ vue : [ [ 'Quickstart' , 'quickstart' ] , [ 'Components and composables' , 'components' ] ] ,
22+ svelte : [ [ 'Quickstart' , 'quickstart' ] , [ 'Components and runes' , 'components' ] ] ,
23+ semantic : [ [ 'Quickstart' , 'quickstart' ] , [ 'Templates and signals' , 'templates' ] ] ,
24+ } ;
25+
26+ // an integration's own exports, listed only where the package exists
27+ const FRAMEWORK_API = {
28+ solid : [ [ 'SolidRouter' , 'solid-router' , true ] , [ 'solidRouter()' , 'solid-router-fn' , true ] ] ,
29+ } ;
30+
31+ const frameworkGroups = ( section ) =>
32+ FRAMEWORKS . flatMap ( ( f ) => {
33+ const items = section === 'guides'
34+ ? FRAMEWORK_GUIDES [ f . id ] ?? [ ]
35+ : f . pkg
36+ ? [ [ 'Overview' , '' ] , ...( FRAMEWORK_API [ f . id ] ?? [ ] ) ]
37+ : [ ] ;
38+ if ( ! items . length ) { return [ ] ; }
39+ return [ {
40+ label : section === 'api' ? f . pkg : f . label ,
41+ framework : f . id ,
42+ items : items . map ( ( [ title , page , symbol ] ) => ( {
43+ title,
44+ slug : [ section , f . slug , page ] . filter ( Boolean ) . join ( '/' ) ,
45+ ...( symbol && { symbol : true } ) ,
46+ } ) ) ,
47+ } ] ;
48+ } ) ;
549
650export const SECTIONS = [
751 {
@@ -16,6 +60,7 @@ export const SECTIONS = [
1660 { title : 'Your first router' , slug : 'guides/first-router' } ,
1761 ] ,
1862 } ,
63+ ...frameworkGroups ( 'guides' ) ,
1964 {
2065 label : 'Routing' ,
2166 items : [
@@ -40,6 +85,7 @@ export const SECTIONS = [
4085 key : 'api' ,
4186 label : 'API' ,
4287 groups : [
88+ ...frameworkGroups ( 'api' ) ,
4389 {
4490 label : 'Classes' ,
4591 items : [
@@ -145,7 +191,11 @@ export function navFor(ids, currentId) {
145191export function pagerFor ( ids , currentId ) {
146192 const exists = new Set ( ids ) ;
147193 const section = SECTIONS . find ( ( s ) => s . key === currentId . split ( '/' ) [ 0 ] ) ;
148- const pages = section . groups . flatMap ( ( g ) => g . items ) . filter ( ( it ) => ! it . slug . includes ( '#' ) && exists . has ( it . slug ) ) ;
194+ // a shared page pages through shared pages; a framework's page through those and its own
195+ const fw = frameworkOf ( currentId ) ;
196+ const pages = section . groups . flatMap ( ( g ) => g . items )
197+ . filter ( ( it ) => ! it . slug . includes ( '#' ) && exists . has ( it . slug ) )
198+ . filter ( ( it ) => [ null , fw ] . includes ( frameworkOf ( it . slug ) ) ) ;
149199 const i = pages . findIndex ( ( it ) => it . slug === currentId ) ;
150200 return { prev : pages [ i - 1 ] ?? null , next : pages [ i + 1 ] ?? null } ;
151201}
0 commit comments